
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
namespace Fcdbas.Core.Windows
{
    public enum SalFormState
    {
        Creating = 1,
        CreatingForm,
        CreatingHandle = 4,
        CreateHidden = 8,
        CreateMaximized = 16,
        Showing = 32,
        Closing = 64,
        Closed = 128,
        Ready = 256
    }
	public class SalWindow
	{
		private class SortedIntList
		{
			private const int defaultCapacity = 10;
			private int count;
			private int[] values;
			public int Count
			{
				get
				{
					return this.count;
				}
			}
			public int this[int index]
			{
				get
				{
					return this.values[index];
				}
			}
			public SortedIntList() : this(10)
			{
			}
			public SortedIntList(int initialCapacity)
			{
				int num = (initialCapacity < 10) ? 10 : initialCapacity;
				this.values = new int[num];
			}
			public void Add(int value)
			{
				if (this.count == this.values.Length)
				{
					this.EnsureCapacity();
				}
				int num = System.Array.BinarySearch<int>(this.values, 0, this.count, value);
				if (num < 0)
				{
					num = ~num;
				}
				System.Array.Copy(this.values, num, this.values, num + 1, this.count - num);
				this.values[num] = value;
				this.count++;
			}
			public int IndexOf(int value)
			{
				int num = System.Array.BinarySearch<int>(this.values, 0, this.count, value);
				if (num >= 0)
				{
					return num;
				}
				return -1;
			}
			public bool Contains(int value)
			{
				return 0 <= System.Array.BinarySearch<int>(this.values, 0, this.count, value);
			}
			private void EnsureCapacity()
			{
				int[] destinationArray = new int[this.values.Length * 2];
				System.Array.Copy(this.values, 0, destinationArray, 0, this.values.Length);
				this.values = destinationArray;
			}
		}
		
		private struct PostMessageQueueItem
		{
			public System.Windows.Forms.Control ctrl;
			public int msg;
			public int wParam;
			public int lParam;
			public PostMessageQueueItem(System.Windows.Forms.Control ctrl, int msg, int wParam, int lParam)
			{
				this.ctrl = ctrl;
				this.msg = msg;
				this.wParam = wParam;
				this.lParam = lParam;
			}
		}
		public class ForcedSynchronousCalls : System.IDisposable
		{
			public ForcedSynchronousCalls()
			{
				SalWindow.ForceSynchronousMode = true;
			}
			public void Dispose()
			{
				SalWindow.ForceSynchronousMode = false;
			}
		}
		[System.ThreadStatic]
		private static int m_disableMessages;
		private static bool m_designMode;
		private static bool m_mapEnterToTab;
		private static bool m_keepMask;
		private static bool m_inWmContextMenu;
		private static bool m_dropDisabled;
		private static System.Windows.Forms.Control m_dragSource;
		private static System.Windows.Forms.Control m_dropTarget;
		private static Point m_dragLocation;
		private static Point m_dropLocation;
		private static System.Windows.Forms.Control m_validating;
		private static bool m_inSendValidateMsg;
		private static int m_setFocusAsyncMessage;
		
		private static SizeF m_dpiScale;
		private static System.Windows.Forms.ProfessionalColorTable m_professionalColors;
		private static System.Windows.Forms.AutoScaleMode m_scaleMode;
		private System.Windows.Forms.Cursor m_dragDropCursor;
		private System.Windows.Forms.Cursor m_disableDropCursor;
		private bool m_dragAcceptFiles;
		private static object m_dropFilesData;
		private static CancelEventHandler m_OnValidate;
		private static System.EventHandler m_OnDisposedHandler;
		

		private ISalWindow m_salWnd;
		private System.Collections.Generic.List<System.Delegate> m_actionsHandlers;
		private SalWindow.SortedIntList m_notHandled;
		private bool m_disposed;
		private bool m_readyToDispatch;
		private static System.Windows.Forms.Timer m_selTimer;
		private static System.Text.StringBuilder m_selBuffer;
		
		private static int[] m_customColors;
		[System.ThreadStatic]
		private static bool enablePostMessageQueueing;
		[System.ThreadStatic]
		private static bool forceNativePostMessageHandling;
		[System.ThreadStatic]
		private static bool idlePostMessageDequeueingDisabled;
		[System.ThreadStatic]
		private static Queue<SalWindow.PostMessageQueueItem> postMessageQueue;
		[System.ThreadStatic]
		private static bool forceSynchronousMode;
		[Browsable(false)]
		public static System.Windows.Forms.ProfessionalColorTable ProfessionalColors
		{
			get
			{
				if (SalWindow.m_professionalColors == null)
				{
					SalWindow.m_professionalColors = new System.Windows.Forms.ProfessionalColorTable();
				}
				return SalWindow.m_professionalColors;
			}
		}
		public static bool MapEnterToTab
		{
			get
			{
				return SalWindow.m_mapEnterToTab;
			}
			set
			{
				SalWindow.m_mapEnterToTab = value;
			}
		}
		public static bool KeepMask
		{
			get
			{
				return SalWindow.m_keepMask;
			}
			set
			{
				SalWindow.m_keepMask = value;
			}
		}
		
		internal System.Windows.Forms.Cursor DragDropCursor
		{
			get
			{
				return this.m_dragDropCursor;
			}
			set
			{
				this.m_dragDropCursor = value;
			}
		}
		internal System.Windows.Forms.Cursor DisableDropCursor
		{
			get
			{
				return this.m_disableDropCursor;
			}
			set
			{
				this.m_disableDropCursor = value;
			}
		}
		internal static string[] DragQueryFiles
		{
			get
			{
				return SalWindow.m_dropFilesData as string[];
			}
		}
		[Browsable(false)]
		public static bool DisableMessages
		{
			get
			{
				return SalWindow.m_disableMessages > 0;
			}
			set
			{
				if (value)
				{
					SalWindow.m_disableMessages++;
					return;
				}
				if (SalWindow.m_disableMessages > 0)
				{
					SalWindow.m_disableMessages--;
				}
			}
		}
		
		internal static SizeF DpiScale
		{
			get
			{
				if (SalWindow.m_dpiScale.IsEmpty)
				{
					using (Graphics graphics = Graphics.FromHwnd(System.IntPtr.Zero))
					{
						SalWindow.m_dpiScale = new SizeF(graphics.DpiX, graphics.DpiY);
					}
				}
				return SalWindow.m_dpiScale;
			}
		}
		internal static System.Windows.Forms.AutoScaleMode ScaleMode
		{
			get
			{
				return SalWindow.m_scaleMode;
			}
			set
			{
				SalWindow.m_scaleMode = value;
			}
		}
		
		internal System.Collections.Generic.List<System.Delegate> WindowsActionsHandlers
		{
			get
			{
				return this.m_actionsHandlers;
			}
		}
		public static bool DesignMode
		{
			get
			{
				return SalWindow.m_designMode;
			}
		}
		public static System.Windows.Forms.Control DragSource
		{
			get
			{
				return SalWindow.m_dragSource;
			}
		}
		public static Point DragLocation
		{
			get
			{
				return SalWindow.m_dragLocation;
			}
		}
		public static System.Windows.Forms.Control DropTarget
		{
			get
			{
				return SalWindow.m_dropTarget;
			}
		}
		public static Point DropLocation
		{
			get
			{
				return SalWindow.m_dropLocation;
			}
		}
		public static bool DropDisabled
		{
			get
			{
				return SalWindow.m_dropDisabled;
			}
			set
			{
				SalWindow.m_dropDisabled = value;
			}
		}
		internal static bool IdlePostMessageDequeueingDisabled
		{
			get
			{
				return SalWindow.idlePostMessageDequeueingDisabled;
			}
			set
			{
				SalWindow.idlePostMessageDequeueingDisabled = value;
			}
		}
		[EditorBrowsable(EditorBrowsableState.Never)]
		public static bool ForceSynchronousMode
		{
			get
			{
				return SalWindow.forceSynchronousMode;
			}
			set
			{
				SalWindow.forceSynchronousMode = value;
			}
		}
		static SalWindow()
		{
			SalWindow.m_designMode = false;
			
			SalWindow.m_selTimer = null;
			SalWindow.m_selBuffer = null;
			
			SalWindow.m_customColors = null;
			SalWindow.forceNativePostMessageHandling = false;
			SalWindow.m_OnValidate = new CancelEventHandler(SalWindow.OnValidate);
			SalWindow.m_OnDisposedHandler = new System.EventHandler(SalWindow.OnDisposed);
			
			
		}
		public SalWindow(ISalWindow salWnd)
		{
			this.m_salWnd = salWnd;
			this.m_actionsHandlers = new System.Collections.Generic.List<System.Delegate>();
			this.m_notHandled = new SalWindow.SortedIntList();
		}
		private void InitializeControl()
		{
			System.Windows.Forms.Control control = (System.Windows.Forms.Control)this.m_salWnd;
			if (!control.RecreatingHandle)
			{
				control.Disposed += SalWindow.m_OnDisposedHandler;
				//if (SalApplication.ThreadModel == System.Threading.ApartmentState.STA)
				{
					control.AllowDrop = true;
					
				}
				if (control is ISalEditControl)
				{
					control.Validating += SalWindow.m_OnValidate;
				}
			}
		}
		private static void OnDisposed(object sender, System.EventArgs e)
		{
			System.Windows.Forms.Control control = (System.Windows.Forms.Control)sender;
			System.Windows.Forms.ContextMenu contextMenu = control.ContextMenu;
			if (contextMenu != null)
			{
				contextMenu.Dispose();
			}
			SalWindow.SetDisposed(control);
		}
		private void DefaultWndProc(ref System.Windows.Forms.Message m)
		{
			if (!this.m_disposed)
			{
				this.m_salWnd.DefaultWndProc(ref m);
			}
		}
		public static implicit operator SalWindow(System.Windows.Forms.Control ctrl)
		{
			ISalWindow salWindow = ctrl as ISalWindow;
			if (salWindow != null)
			{
				return salWindow.GetSalWindowImpl();
			}
			return null;
		}
		public void ProcessWndProc(ref System.Windows.Forms.Message m)
		{
			if (SalWindow.DisableMessages || SalWindow.DesignMode || this.m_disposed)
			{
				this.DefaultWndProc(ref m);
				return;
			}
			int msg = m.Msg;
			if (msg <= 125)
			{
				if (msg <= 16)
				{
					switch (msg)
					{
					case 1:
					case 5:
					case 10:
						break;
					case 2:
						this.WmDestroy(ref m);
						return;
					case 3:
					case 4:
					case 6:
					case 9:
						goto IL_139;
					case 7:
						this.WmSetFocus(ref m);
						return;
					case 8:
						this.WmKillFocus(ref m);
						return;
					default:
						if (msg != 16)
						{
							goto IL_139;
						}
						this.WmClose(ref m);
						return;
					}
				}
				else
				{
					if (msg != 71)
					{
						switch (msg)
						{
						case 123:
							this.WmContextMenu(ref m);
							return;
						case 124:
							goto IL_139;
						case 125:
							break;
						default:
							goto IL_139;
						}
					}
				}
			}
			else
			{
				if (msg <= 279)
				{
					if (msg == 129)
					{
						this.WmNcCreate(ref m);
						return;
					}
					switch (msg)
					{
					case 278:
					case 279:
						break;
					default:
						goto IL_139;
					}
				}
				else
				{
					
					switch (msg)
					{
					case 8465:
						this.WmReflectedCommand(ref m);
						return;
					case 8466:
					case 8467:
						goto IL_139;
					case 8468:
						this.WmReflectedScroll(ref m);
						return;
					case 8469:
						this.WmReflectedScroll(ref m);
						return;
					default:
						goto IL_139;
					}
				}
			}
			this.ProcessThenDispatch(ref m);
			return;
			IL_139:
			this.DispatchThenProcess(ref m);
		}
		private void DispatchThenProcess(ref System.Windows.Forms.Message m)
		{
			if (SalWindow.m_setFocusAsyncMessage != 0 && m.Msg == SalWindow.m_setFocusAsyncMessage)
			{
				((System.Windows.Forms.Control)this.m_salWnd).Focus();
				return;
			}
			WindowActionsEventArgs windowActionsEventArgs = this.FireWindowActions(m.Msg, m.WParam, m.LParam);
			if (windowActionsEventArgs.HasReturnValue)
			{
				m.Result = windowActionsEventArgs.Return;
				return;
			}
			this.DefaultWndProc(ref m);
		}
		private void ProcessThenDispatch(ref System.Windows.Forms.Message m)
		{
			this.DefaultWndProc(ref m);
			this.FireWindowActions(m.Msg, m.WParam, m.LParam);
		}
		private void WmNcCreate(ref System.Windows.Forms.Message m)
		{
			this.DefaultWndProc(ref m);
			if (!SalWindow.m_designMode)
			{
				ISite site = ((System.Windows.Forms.Control)this.m_salWnd).Site;
				if (site != null && site.DesignMode)
				{
					SalWindow.m_designMode = true;
				}
				else
				{
					this.InitializeControl();
				}
			}
			this.FireWindowActions(m.Msg, m.WParam, m.LParam);
		}
		private void WmClose(ref System.Windows.Forms.Message m)
		{
			System.Windows.Forms.Form form = this.m_salWnd as System.Windows.Forms.Form;
			if (SalWindow.GetFormState(form, SalFormState.Closed) || SalWindow.GetFormState(form, SalFormState.Closing))
			{
				this.DefaultWndProc(ref m);
				return;
			}
			if (!SalWindow.GetFormState(form, SalFormState.Closing))
			{
				SalWindow.SetFormState(form, SalFormState.Closing, true);
				try
				{
					WindowActionsEventArgs windowActionsEventArgs = this.FireWindowActions(16, m.WParam, m.LParam);
					if (windowActionsEventArgs.HasReturnValue)
					{
						m.Result = windowActionsEventArgs.Return;
						return;
					}
				}
				finally
				{
					SalWindow.SetFormState(form, SalFormState.Closing, false);
				}
			}
			if (!SalWindow.GetFormState(form, SalFormState.Closed))
			{
				if (form == null)
				{
					WinSDK.DestroyWindow(m.HWnd);
					return;
				}
				SalWindow.SetFormState(form, SalFormState.Closing, true);
				try
				{
					this.DefaultWndProc(ref m);
				}
				finally
				{
					SalWindow.SetFormState(form, SalFormState.Closing, false);
					if (form.IsDisposed || form.Modal)
					{
						SalWindow.SetFormState(form, SalFormState.Closed, true);
					}
				}
				return;
			}
		}
		private void WmDestroy(ref System.Windows.Forms.Message m)
		{
			System.Windows.Forms.Control control = (System.Windows.Forms.Control)this.m_salWnd;
			if (control.RecreatingHandle)
			{
                //Sys.TraceInfo(Sys.TraceWindows, "Recreate: Handle: Message=\"Recreating the handle for {0}({1}).\"", new object[]
                //{
                //    control.Name,
                //    control.GetType().FullName
                //});
			}
			this.FireWindowActions(m.Msg, m.WParam, m.LParam);
			if (!control.RecreatingHandle)
			{
				this.FireWindowActions(8194, m.WParam, m.LParam);
			}
			this.DefaultWndProc(ref m);
		}
		private void WmSetFocus(ref System.Windows.Forms.Message m)
		{
			System.Windows.Forms.Control control = (System.Windows.Forms.Control)this.m_salWnd;
			if (m.HWnd == control.Handle)
			{
				WindowActionsEventArgs windowActionsEventArgs = this.FireWindowActions(m.Msg, m.WParam, m.LParam);
				if (!windowActionsEventArgs.HasReturnValue)
				{
					this.DefaultWndProc(ref m);
				}
			}
			if (control.Focused)
			{
				this.FireWindowActions(4103, SalWindow.TranslateFocus(m.WParam).ToIntPtr(), System.IntPtr.Zero);
				System.Windows.Forms.Form form = SalWindow.FindTopForm(control);
				if (form != null && form != control)
				{
					form.Activate();
				}
			}
		}
		private void WmKillFocus(ref System.Windows.Forms.Message m)
		{
			System.Windows.Forms.Control control = (System.Windows.Forms.Control)this.m_salWnd;
			if (m.HWnd == control.Handle)
			{
				WindowActionsEventArgs windowActionsEventArgs = this.FireWindowActions(m.Msg, m.WParam, m.LParam);
				if (!windowActionsEventArgs.HasReturnValue)
				{
					this.DefaultWndProc(ref m);
				}
			}
            this.FireWindowActions(Sys.SAM_KillFocus, SalWindow.TranslateFocus(m.WParam).ToIntPtr(), System.IntPtr.Zero);
		}
		private void WmContextMenu(ref System.Windows.Forms.Message m)
		{
			WindowActionsEventArgs windowActionsEventArgs = this.FireWindowActions(m.Msg, m.WParam, m.LParam);
			if (windowActionsEventArgs.HasReturnValue)
			{
				return;
			}
			if (!SalWindow.m_inWmContextMenu)
			{
				System.Windows.Forms.Control control = (System.Windows.Forms.Control)this.m_salWnd;
                //if (control is SalFormToolBar)
                //{
                //    control = control.Parent;
                //}
				Point mousePositionFromLParam = SalWindow.GetMousePositionFromLParam(m.LParam);
				if (control.ClientRectangle.Contains(control.PointToClient(mousePositionFromLParam)))
				{
					control = SalWindow.TranslateControl(control);
					windowActionsEventArgs = SalWindow.FireWindowActions(control, 8264, mousePositionFromLParam.X, mousePositionFromLParam.Y);
					if (windowActionsEventArgs.HasReturnValue)
					{
						return;
					}
				}
			}
			try
			{
				SalWindow.m_inWmContextMenu = true;
				this.DefaultWndProc(ref m);
			}
			finally
			{
				SalWindow.m_inWmContextMenu = false;
			}
		}
		private void WmReflectedCommand(ref System.Windows.Forms.Message m)
		{
			this.DefaultWndProc(ref m);
			if (this.m_salWnd.GetWindowType() == 67108864)
			{
				int wParam = (int)m.WParam >> 16;
                this.FireWindowActions(Sys.SAM_CustControlCmd, wParam, 0);
			}
		}
        //private void WmReflectedNotify(ref System.Windows.Forms.Message m)
        //{
        //    this.DefaultWndProc(ref m);
        //    if (this.m_salWnd.GetWindowType() == 67108864)
        //    {
        //        this.FireWindowActions(8249, ((CommonControls.NMHDR)m.GetLParam(typeof(CommonControls.NMHDR))).code, 0);
        //    }
        //}
		private void WmReflectedScroll(ref System.Windows.Forms.Message m)
		{
			int msgCode = m.Msg & -8193;
			WindowActionsEventArgs windowActionsEventArgs = this.FireWindowActions(msgCode, m.WParam, m.LParam);
			if (!windowActionsEventArgs.HasReturnValue)
			{
				this.DefaultWndProc(ref m);
			}
		}
        //internal WindowActionsEventArgs FireWindowActions(int msgCode, object wParam, object lParam)
        //{
        //    return this.FireWindowActions(msgCode, wParam, lParam);
        //}
        internal WindowActionsEventArgs FireWindowActions(int msgCode, object wParam, object lParam)
		{
			if (!this.ShouldDispatch(msgCode))
			{
				return WindowActionsEventArgs.Empty;
			}
			System.Windows.Forms.Control ctrl = (System.Windows.Forms.Control)this.m_salWnd;
			WindowActionsEventArgs windowActionsEventArgs = new WindowActionsEventArgs(ctrl, msgCode, wParam, lParam);
			SalContext salContext = new SalContext(ctrl, true);
			using (salContext)
			{
				this.InvokeWindowActions(windowActionsEventArgs, salContext, 0, null);
			}
			return windowActionsEventArgs;
		}
		private void InvokeWindowActions(WindowActionsEventArgs args, SalContext context, int startIndex, System.Type startType)
		{
			object wParam = Sys.wParam;
			object lParam = Sys.lParam;
			int windowActionsIndex = context.WindowActionsIndex;
			try
			{
				bool flag = startType == null;
                int num = startIndex;
				bool flag2 = false;
                if (num == -1)
                {
                    flag2 = (startType == null);
                    num = this.m_actionsHandlers.Count - 1;
                }
                else
                    num = this.m_actionsHandlers.Count;
				//for (int i = num; i > -1; i--)
                for (int i = 0; i < num; i++)
				{
					System.Delegate @delegate = this.m_actionsHandlers[i];
					if (!flag && startType != null)
					{
						System.Type declaringType = @delegate.Method.DeclaringType;
						if (TypeManager.IsDerivedFrom(startType, declaringType))
						{
							flag = true;
						}
					}
					if (flag)
					{
						context.WindowActionsIndex = i;
						Sys.wParam = args.WParam;
						Sys.lParam = args.LParam;
						WindowActionsEventHandler windowActionsEventHandler = @delegate as WindowActionsEventHandler;
						if (windowActionsEventHandler != null)
						{
							windowActionsEventHandler(context.Control, args);
						}
						
						this.TraceWindowActions(args);
						if (args.Handled || args.HasReturnValue)
						{
							return;
						}
					}
				}
                //if (flag2)
                //{
                //    this.SetNotHandled(args.ActionType);
                //}
			}
			finally
			{
				Sys.wParam = wParam;
				Sys.lParam = lParam;
				context.WindowActionsIndex = windowActionsIndex;
			}
		}
		private bool ShouldDispatch(int code)
		{
			return this.m_actionsHandlers != null && this.m_actionsHandlers.Count != 0 && !SalWindow.DisableMessages && !SalWindow.DesignMode && !this.IsNotHandled(code) && !this.m_disposed && SalWindow.IsReadyToDispatch(this);
		}
		private bool IsNotHandled(int code)
		{
			return this.m_notHandled.Contains(code);
		}
		private void SetNotHandled(int code)
		{
			this.m_notHandled.Add(code);
		}
        //[System.Obsolete("Deprecated. Use AddWindowActions()")]
        //public void AddMessageActions(System.Delegate handler)
        //{
        //    if (!this.m_actionsHandlers.Contains(handler))
        //    {
        //        this.m_actionsHandlers.Add(handler);
        //    }
        //}
        //[System.Obsolete("Deprecated. Use RemoveWindowActions()")]
        //public void RemoveMessageActions(System.Delegate handler)
        //{
        //    this.m_actionsHandlers.Remove(handler);
        //}
        //[System.Obsolete("Deprecated. Use AddWindowActions().")]
        //public void AddMessageActions(ISalWindow target)
        //{
        //    this.AddWindowActions(target);
        //}
		public void AddWindowActions(System.Delegate handler)
		{
			if (!this.m_actionsHandlers.Contains(handler))
			{
				this.m_actionsHandlers.Add(handler);
			}
		}
		public void AddWindowActions(ISalWindow target)
		{
			System.Collections.Generic.List<System.Delegate> actionsHandlers = SalWindow.GetActionsHandlers(target);
			foreach (System.Delegate current in actionsHandlers)
			{
				this.AddWindowActions(current);
			}
		}
		public void RemoveWindowActions(System.Delegate handler)
		{
			this.m_actionsHandlers.Remove(handler);
		}
		public static System.Collections.Generic.List<System.Delegate> GetActionsHandlers(ISalWindow target)
		{
			
			return target.GetSalWindowImpl().m_actionsHandlers;
		}
		internal static Point GetMousePositionFromLParam(System.IntPtr lParam)
		{
			int num = (int)lParam;
			return new Point((int)((short)(num & 65535)), (int)((short)(num >> 16 & 65535)));
		}
        public static WindowActionsEventArgs FireWindowActions(System.Windows.Forms.Control ctrl, int msgCode, object wParam, object lParam)
		{
			ctrl = SalWindow.GetDerivedInstance(ctrl);
			SalWindow salWindow = ctrl;
			if (salWindow == null)
			{
				return WindowActionsEventArgs.Empty;
			}
			return salWindow.FireWindowActions(msgCode, wParam, lParam);
		}
		
		public static System.Windows.Forms.Control GetLabel(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return null;
			}
			System.Windows.Forms.Form form = ctrl.FindForm();
			if (form is ISalForm)
			{
				return ((ISalForm)form).GetLabel(ctrl);
			}
			if (form != null)
			{
				return SalWindow.FindLabelInternal(ctrl);
			}
			return null;
		}
		public static void SetLabel(System.Windows.Forms.Control ctrl, System.Windows.Forms.Control label)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return;
			}
			System.Windows.Forms.Form form = ctrl.FindForm();
			if (form is ISalForm)
			{
				((ISalForm)form).SetLabel(ctrl, label);
			}
		}
		private static System.Windows.Forms.Label FindLabelInternal(System.Windows.Forms.Control ctrl)
		{
			int num = -1;
			System.Windows.Forms.Label label = null;
			int tabIndex = ctrl.TabIndex;
			System.Windows.Forms.Control.ControlCollection controls = ctrl.Parent.Controls;
			foreach (System.Windows.Forms.Control control in controls)
			{
				if (control.TabIndex < tabIndex && control.TabIndex > num)
				{
					label = (control as System.Windows.Forms.Label);
					if (label != null)
					{
						num = control.TabIndex;
					}
				}
			}
			return label;
		}
		private static void OnValidate(object sender, CancelEventArgs e)
		{
			System.Windows.Forms.Control control = (System.Windows.Forms.Control)sender;
			if (control.Disposing || control.IsDisposed)
			{
				return;
			}
			if (!SalWindow.ShouldValidate(control))
			{
				return;
			}
			if (!SalWindow.IsParentFormActive(control))
			{
				return;
			}
			if (SalWindow.Validate(control, 0) == 0)
			{
				e.Cancel = true;
			}
		}
		internal static bool ShouldValidate(System.Windows.Forms.Control ctrl)
		{
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			return salEditControl != null && salEditControl.Modified && !salEditControl.Validated && (!(ctrl is System.Windows.Forms.ComboBox) || ((System.Windows.Forms.ComboBox)ctrl).DropDownStyle != System.Windows.Forms.ComboBoxStyle.DropDownList);
		}
		internal static bool IsParentFormActive(System.Windows.Forms.Control ctrl)
		{
			System.Windows.Forms.Form form = SalWindow.FindTopForm(ctrl);
			if (form != null && form is ISalForm)
			{
				if (form.IsMdiChild)
				{
					form = form.MdiParent;
				}
				return System.Windows.Forms.Form.ActiveForm == form;
			}
			return true;
		}
		internal static bool IsTopLevelFormActive(System.Windows.Forms.Control ctrl)
		{
			System.Windows.Forms.Form form = SalWindow.FindTopForm(ctrl);
			if (form != null && form is ISalForm)
			{
				if (form.IsMdiChild)
				{
					form = form.MdiParent;
				}
				return System.Windows.Forms.Form.ActiveForm == form;
			}
			return true;
		}
		internal static System.Windows.Forms.Form FindTopForm(System.Windows.Forms.Control ctrl)
		{
			if (ctrl == null)
			{
				return null;
			}
			System.Windows.Forms.Form form = ctrl.FindForm();
			if (form == null)
			{
				//Control salNativeControl = ctrl as SalNativeControl;
                if (ctrl != null)
				{
					//ctrl = salNativeControl.Parent;
					if (ctrl != null)
					{
						form = ctrl.FindForm();
					}
				}
			}
			while (form != null && !form.TopLevel && !form.IsMdiChild && form.Parent != null)
			{
				form = form.Parent.FindForm();
			}
			return form;
		}
		internal static int Validate(System.Windows.Forms.Control ctrl, int lParam)
		{
			if (SalWindow.IsValidating(ctrl))
			{
				return 0;
			}
			SalWindow.m_validating = ctrl;
			int result;
			try
			{
				result = SalWindow.ValidateInternal(ctrl, 0, lParam, true);
			}
			finally
			{
				SalWindow.m_validating = null;
			}
			return result;
		}
		private static int ValidateInternal(System.Windows.Forms.Control ctrl, int wParam, int lParam, bool focusChanged)
		{
			if (!SalWindow.ShouldValidate(ctrl))
			{
				return 1;
			}
			if (focusChanged && SalWindow.IsFormClosedOrClosing(SalWindow.FindTopForm(ctrl)))
			{
				return 1;
			}
			System.Windows.Forms.Form form = null;
			System.Windows.Forms.Control control = null;
			bool flag = false;
			bool flag2 = false;
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (focusChanged)
			{
				form = ctrl.FindForm();
				while (form != null && form.ActiveControl == null && form.Parent != null)
				{
					form = form.Parent.FindForm();
				}
				control = ((form == null) ? null : form.ActiveControl);
				
				if (control is System.Windows.Forms.IButtonControl)
				{
					flag2 = control.Capture;
					flag = SalWindow.IsDeferredClick(control);
				}
			}
			salEditControl.Validated = true;
			int num = 1;
			wParam = ((control == null) ? wParam : ((int)control.Handle));
			WindowActionsEventArgs windowActionsEventArgs = SalWindow.FireWindowActions(ctrl, 8204, wParam, lParam);
			if (windowActionsEventArgs.HasReturnValue)
			{
				num = windowActionsEventArgs.Return;
				switch (num)
				{
				case 0:
				case 1:
					salEditControl.Modified = true;
					break;
				case 2:
					num = 1;
					salEditControl.Modified = false;
					break;
				default:
					salEditControl.Modified = true;
					if (num != 2147483647)
					{
						num = 0;
					}
					break;
				}
			}
			else
			{
				salEditControl.Modified = true;
				if (!salEditControl.ValidateDataType())
				{
					SalWindow.ShowInvalidDataMsgBox(salEditControl);
					num = 0;
				}
			}
			if (num == 0)
			{
				salEditControl.Validated = false;
			}
			else
			{
				salEditControl.Validated = true;
				if (salEditControl.ValidateDataType())
				{
					salEditControl.ApplyFormat();
				}
				SalWindow.SendSamFieldEdit(ctrl);
				if (flag)
				{
					if (!control.Capture && form.ActiveControl == control)
					{
						((System.Windows.Forms.IButtonControl)control).PerformClick();
					}
					if (!flag2)
					{
						control.Capture = false;
					}
				}
			}
			return num;
		}
		private static void ShowInvalidDataMsgBox(ISalEditControl editCtrl)
		{
			System.Windows.Forms.Control ctrl = (System.Windows.Forms.Control)editCtrl;
			string textWithMask = SalWindow.GetTextWithMask(ctrl);
			if (!SalWindow.IsTopLevelFormActive(ctrl))
			{
				return;
			}
			string text;
			switch (editCtrl.GetDataType())
			{
			case 2:
				text = Sys.GetString("InvalidDateTimeValue");
				break;
			case 3:
				text = Sys.GetString("InvalidNumberValue");
				break;
			default:
				return;
			}
			text = string.Format(text, textWithMask);
			//Sal.MessageBox(text, SalApplication.Title, 0);
		}
		private static bool IsDeferredClick(System.Windows.Forms.Control btn)
		{
			if (btn != null && btn.Parent != null && System.Windows.Forms.Control.MouseButtons == System.Windows.Forms.MouseButtons.Left && btn.Parent.RectangleToScreen(btn.Bounds).Contains(System.Windows.Forms.Control.MousePosition))
			{
				btn.Capture = true;
				return true;
			}
			return false;
		}
		
		private static void PixelsToFormUnits(Size scale, int pixelsX, int pixelsY, out float unitsX, out float unitsY)
		{
			int num = scale.Width * 10;
			int num2 = (scale.Height + 1) / 2 * 12;
			int num3 = (pixelsX < 0) ? (-(num / 2)) : (num / 2);
			int num4 = (pixelsY < 0) ? (-(num2 / 2)) : (num2 / 2);
			unitsX = (float)((pixelsX * 1000 + num3) / num) / 1000f;
			unitsY = (float)((pixelsY * 1000 + num4) / num2) / 1000f;
		}
		private static void FormUnitsToPixels(Size scale, float unitsX, float unitsY, out int pixelsX, out int pixelsY)
		{
			int num = scale.Width * 10;
			int num2 = (scale.Height + 1) / 2 * 12;
			int num3 = (int)(unitsX * 1000f);
			int num4 = (int)(unitsY * 1000f);
			pixelsX = (num3 * num + ((num3 < 0) ? -500 : 500)) / 1000;
			pixelsY = (num4 * num2 + ((num4 < 0) ? -500 : 500)) / 1000;
		}
		internal static void ScaleForm(System.Windows.Forms.Form form, Size oldScale, Size newScale)
		{
			if (oldScale != newScale && !oldScale.IsEmpty)
			{
				lock (typeof(SalWindow))
				{
					try
					{
						form.SuspendLayout();
						form.MaximumSize = SalWindow.Scale(form.MaximumSize, oldScale, newScale);
						Size size = form.RestoreBounds.Size;
						if (form.WindowState == System.Windows.Forms.FormWindowState.Normal)
						{
							form.ClientSize = SalWindow.Scale(form.ClientSize, oldScale, newScale);
						}
						form.Size = SalWindow.Scale(size, oldScale, newScale);
						form.MinimumSize = SalWindow.Scale(form.MinimumSize, oldScale, newScale);
						if (form.HasChildren)
						{
							foreach (System.Windows.Forms.Control ctrl in form.Controls)
							{
								SalWindow.ScaleControl(ctrl, oldScale, newScale);
							}
						}
					}
					finally
					{
						form.ResumeLayout(false);
					}
				}
			}
		}
		private static void ScaleControl(System.Windows.Forms.Control ctrl, Size oldScale, Size newScale)
		{
			Rectangle bounds = ctrl.Bounds;
			Size size = bounds.Size;
			Point point = bounds.Location;
			try
			{
				ctrl.SuspendLayout();
				size = SalWindow.Scale(size, oldScale, newScale);
				point = SalWindow.Scale(point, oldScale, newScale);
				ctrl.SetBounds(point.X, point.Y, size.Width, size.Height);
				SalWindow.ScalePadding(ctrl, oldScale, newScale);
				if (ctrl.HasChildren)
				{
					if (SalWindow.m_scaleMode != System.Windows.Forms.AutoScaleMode.Font || !(ctrl is System.Windows.Forms.UserControl) || ctrl.Font == ctrl.Parent.Font)
					{
						foreach (System.Windows.Forms.Control control in ctrl.Controls)
						{
							if (!control.GetType().IsSubclassOf(typeof(ISalForm)))
							{
								SalWindow.ScaleControl(control, oldScale, newScale);
							}
						}
					}
				}
			}
			finally
			{
				ctrl.ResumeLayout(false);
			}
		}
		private static void ScalePadding(System.Windows.Forms.Control ctrl, Size oldScale, Size newScale)
		{
			System.Windows.Forms.Padding padding = ctrl.Padding;
			if (padding.All != 0 && oldScale != newScale)
			{
				Size size = new Size(padding.Left, padding.Top);
				Size size2 = new Size(padding.Right, padding.Bottom);
				size = SalWindow.Scale(size, oldScale, newScale);
				size2 = SalWindow.Scale(size2, oldScale, newScale);
				ctrl.Padding = new System.Windows.Forms.Padding(size.Width, size.Height, size2.Width, size2.Height);
			}
		}
		public static Size Scale(Size size, Size oldScale, Size newScale)
		{
			Size result = size;
			if (!size.IsEmpty && oldScale != newScale)
			{
				int width = 0;
				int height = 0;
				float unitsX = 0f;
				float unitsY = 0f;
				SalWindow.PixelsToFormUnits(oldScale, size.Width, size.Height, out unitsX, out unitsY);
				SalWindow.FormUnitsToPixels(newScale, unitsX, unitsY, out width, out height);
				result.Width = width;
				result.Height = height;
			}
			return result;
		}
		public static Point Scale(Point point, Size oldScale, Size newScale)
		{
			Point result = point;
			if (!point.IsEmpty)
			{
				int x = 0;
				int y = 0;
				float unitsX = 0f;
				float unitsY = 0f;
				SalWindow.PixelsToFormUnits(oldScale, point.X, point.Y, out unitsX, out unitsY);
				SalWindow.FormUnitsToPixels(newScale, unitsX, unitsY, out x, out y);
				result.X = x;
				result.Y = y;
			}
			return result;
		}
		private static System.Windows.Forms.Form CreateWindowInternal(System.Type t, object[] args)
		{
			if (t == null)
			{
				throw SalWindow.InvalidFormTemplateError(t);
			}
			System.Reflection.ConstructorInfo constructorInfo = null;
			System.Reflection.ConstructorInfo[] constructors = t.GetConstructors();
			System.Reflection.ConstructorInfo[] array = constructors;
			for (int i = 0; i < array.Length; i++)
			{
				System.Reflection.ConstructorInfo constructorInfo2 = array[i];
				if (constructorInfo2.GetParameters().Length == args.Length)
				{
					constructorInfo = constructorInfo2;
					break;
				}
			}
			if (constructorInfo == null)
			{
				throw SalWindow.WrongNumberOfWindowParameters(t);
			}
			System.Reflection.ParameterInfo[] parameters = constructorInfo.GetParameters();
			object[] array2 = new object[args.Length];
			for (int j = 0; j < args.Length; j++)
			{
				object obj = args[j];
				System.Type parameterType = parameters[j].ParameterType;
				if (parameterType != obj.GetType())
				{
					if (parameterType == typeof(SalNumber))
					{
						System.IConvertible convertible = obj as System.IConvertible;
						if (convertible != null)
						{
							obj = convertible.ToDecimal(null);
						}
					}
					obj = TypeManager.ConvertToType(obj, parameters[j].ParameterType);
				}
				array2[j] = obj;
			}
			return (System.Windows.Forms.Form)constructorInfo.Invoke(array2);
		}
		private static bool DoClipboardCommand(int cmd)
		{
			SalWindowHandle salWindowHandle = SalWindow.GetFocus();
			
			System.IntPtr intPtr = salWindowHandle.Value;
			if (intPtr == System.IntPtr.Zero)
			{
				return false;
			}
			
			switch (cmd)
			{
			case 768:
			case 769:
			case 770:
			case 771:
			case 772:
			//	WinSDK.SendMessage(intPtr, cmd, System.IntPtr.Zero, System.IntPtr.Zero);
				return true;
			default:
				return false;
			}
		}
		private static bool CanDoClipboardCommand(int cmd)
		{
			SalWindowHandle handle = SalWindow.GetFocus();
			
			System.IntPtr value = handle.Value;
			if (value == System.IntPtr.Zero)
			{
				return false;
			}
			switch (cmd)
			{
			case 768:
			case 771:
				return SalWindow.CanCut(handle);
			case 769:
				return SalWindow.CanCopy(handle);
			case 770:
				return SalWindow.CanPaste(handle);
			case 772:
				return WinSDK.SendMessage(WinSDK.GetFocus(), 198, System.IntPtr.Zero, System.IntPtr.Zero) != System.IntPtr.Zero;
			default:
				return false;
			}
		}
		private static bool CanCut(System.Windows.Forms.Control ctrl)
		{
			return ctrl != null && ctrl.Enabled && (!(ctrl is System.Windows.Forms.TextBoxBase) || !((System.Windows.Forms.TextBoxBase)ctrl).ReadOnly) && (!(ctrl is System.Windows.Forms.ComboBox) || ((System.Windows.Forms.ComboBox)ctrl).DropDownStyle == System.Windows.Forms.ComboBoxStyle.DropDown) && (!(ctrl is System.Windows.Forms.RichTextBox) || !((System.Windows.Forms.RichTextBox)ctrl).ReadOnly)  && SalWindow.CanCopy(ctrl);
		}
		private static bool CanCopy(System.Windows.Forms.Control ctrl)
		{
			if (ctrl == null)
			{
				return false;
			}
			if (ctrl is System.Windows.Forms.TextBoxBase)
			{
				return ((System.Windows.Forms.TextBoxBase)ctrl).SelectionLength > 0;
			}
			if (ctrl is System.Windows.Forms.ComboBox)
			{
				return ((System.Windows.Forms.ComboBox)ctrl).SelectionLength > 0;
			}
			if (ctrl is System.Windows.Forms.RichTextBox)
			{
				return ((System.Windows.Forms.RichTextBox)ctrl).SelectionLength > 0;
			}
			
			
			return ctrl.Text.Length > 0;
		}
		private static bool CanPaste(System.Windows.Forms.Control ctrl)
		{
			if (ctrl == null || !ctrl.Enabled || !SalWindow.ClipboardHasData(System.Windows.Forms.DataFormats.UnicodeText))
			{
				return false;
			}
			if (ctrl is System.Windows.Forms.TextBoxBase)
			{
				return !((System.Windows.Forms.TextBoxBase)ctrl).ReadOnly;
			}
			if (ctrl is System.Windows.Forms.ComboBox)
			{
				return ((System.Windows.Forms.ComboBox)ctrl).DropDownStyle != System.Windows.Forms.ComboBoxStyle.DropDownList;
			}
			if (ctrl is System.Windows.Forms.RichTextBox)
			{
				return !((System.Windows.Forms.RichTextBox)ctrl).ReadOnly;
			}
            return false;
			
		}
		private static bool ClipboardHasData(string dataFormat)
		{
			try
			{
				System.Windows.Forms.IDataObject dataObject = System.Windows.Forms.Clipboard.GetDataObject();
				if (dataObject != null && dataObject.GetDataPresent(dataFormat, true))
				{
					return true;
				}
			}
			catch (System.Exception e)
			{
				Sys.TraceException(Sys.TraceWindows, e, TraceLevel.Error);
			}
			return false;
		}
		private static bool IsEditControl(System.Windows.Forms.Control ctrl)
		{
			return ctrl is ISalEditControl || ctrl is System.Windows.Forms.TextBoxBase || (ctrl is System.Windows.Forms.ComboBox && ((System.Windows.Forms.ComboBox)ctrl).DropDownStyle == System.Windows.Forms.ComboBoxStyle.DropDown);
		}
		private static System.Globalization.CultureInfo GetCultureInfo(System.Windows.Forms.Control ctrl)
		{
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return null;
			}
			return salEditControl.CultureInfo;
		}
		
		internal static System.Windows.Forms.Control GetDerivedInstance(System.Windows.Forms.Control ctrl)
		{
			ISalWindow salWindow = ctrl as ISalWindow;
			if (salWindow == null)
			{
				return ctrl;
			}
			object derived = salWindow.Derived;
			if (derived == null)
			{
				return ctrl;
			}
			return SalWindow.GetDerivedInstance(derived as System.Windows.Forms.Control);
		}
        internal static SalWindowHandle TranslateFocus(System.IntPtr handle)
        {
            System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle(handle);
            if (control == null)
            {
                control = System.Windows.Forms.Control.FromHandle(WinSDK.GetParent(handle));
                if (control == null)
                {
                    return handle;
                }
                if (!(control is System.Windows.Forms.ComboBox))
                {
                    return handle;
                }
            }
            
            return control;
        }
        //private static System.Windows.Forms.Control TranslateFocusTableWidow(SalTableWindow table)
        //{
        //    SalTableColumn activeColumn = table.ActiveColumn;
        //    if (activeColumn != null && activeColumn.Enabled)
        //    {
        //        return activeColumn;
        //    }
        //    if (table.IsEmbedded)
        //    {
        //        return table.Parent;
        //    }
        //    return table;
        //}
        //private static System.Windows.Forms.ContextMenu CreateContextNamedMenu(System.Type menuType)
        //{
        //    if (menuType != null)
        //    {
        //        try
        //        {
        //            System.Windows.Forms.MenuItem menu = (System.Windows.Forms.MenuItem)System.Activator.CreateInstance(menuType);
        //            return new SalContextMenu(menu);
        //        }
        //        catch (System.Reflection.TargetInvocationException ex)
        //        {
        //            Sys.TraceException(Sys.TraceWindows, ex, TraceLevel.Error);
        //            throw ex.InnerException;
        //        }
        //    }
        //    return null;
        //}
        //private static System.Type FindNamedMenu(System.Windows.Forms.Control ctrl, string name)
        //{
        //    if (ctrl == null)
        //    {
        //        return null;
        //    }
        //    System.Type type = null;
        //    if (name.IndexOf('.') > -1)
        //    {
        //        type = Sal.ResolveType(System.Reflection.Assembly.GetEntryAssembly(), name);
        //    }
        //    if (type == null)
        //    {
        //        System.Windows.Forms.Form form = ctrl.FindForm();
        //        if (form != null)
        //        {
        //            type = TypeManager.LookupNamedMenu(form.GetType().Name, name);
        //        }
        //        if (type == null && SalApplication.ApplicationType != null)
        //        {
        //            type = TypeManager.LookupNamedMenu(SalApplication.ApplicationType.Name, name);
        //        }
        //        if (type == null)
        //        {
        //            type = TypeManager.LookupNamedMenu("App", name);
        //        }
        //        if (type == null)
        //        {
        //            type = TypeManager.LookupNamedMenu("Application", name);
        //        }
        //    }
        //    if (type != null && !type.IsSubclassOf(typeof(System.Windows.Forms.MenuItem)))
        //    {
        //        throw new System.ArgumentException(string.Format(Sys.GetString("InvalidNamedMenuClass"), type.FullName));
        //    }
        //    return type;
        //}
        internal static System.Windows.Forms.Control FindMenuOwner(System.Windows.Forms.MenuItem menu)
		{
			System.Windows.Forms.Control control = SalWindow.FindMenuContext(menu);
			if (control != null)
			{
				control = control.FindForm();
			}
			return control;
		}
		internal static System.Windows.Forms.Control FindMenuContext(System.Windows.Forms.MenuItem menu)
		{
			System.Windows.Forms.Control control = null;
			System.Windows.Forms.MainMenu mainMenu = menu.GetMainMenu();
			if (mainMenu != null)
			{
				control = mainMenu.GetForm();
			}
			else
			{
				System.Windows.Forms.ContextMenu contextMenu = menu.GetContextMenu();
				if (contextMenu != null)
				{
					control = contextMenu.SourceControl;
				}
			}
			if (control == null)
			{
				control = SalContext.Current.Control;
			}
			return control;
		}
        //internal int FixAccessoriesOrder()
        //{
        //    System.Windows.Forms.Form form = this.m_salWnd as System.Windows.Forms.Form;
        //    if (form == null)
        //    {
        //        return 0;
        //    }
        //    System.Windows.Forms.Control control = SalWindow.FindAccessory(form, AccessoryType.ToolBar);
        //    System.Windows.Forms.Control control2 = SalWindow.FindAccessory(form, AccessoryType.StatusBar);
        //    System.Windows.Forms.Control control3 = SalWindow.FindAccessory(form, AccessoryType.ClientArea);
        //    int result = 0;
        //    if (control != null)
        //    {
        //        form.Controls.SetChildIndex(control, result++);
        //    }
        //    if (control2 != null)
        //    {
        //        form.Controls.SetChildIndex(control2, result++);
        //    }
        //    if (control3 != null)
        //    {
        //        form.Controls.SetChildIndex(control3, result++);
        //    }
        //    return result;
        //}
        //public static bool HasAccessories(System.Windows.Forms.Control ctrl)
        //{
        //    System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
        //    if (form == null || !form.HasChildren)
        //    {
        //        return false;
        //    }
        //    foreach (System.Windows.Forms.Control control in form.Controls)
        //    {
        //        if (control is ISalAccessory)
        //        {
        //            return true;
        //        }
        //    }
        //    return false;
        //}
		private static bool GetFormState(System.Windows.Forms.Form form, SalFormState state)
		{
			ISalForm salForm = form as ISalForm;
			return salForm != null && salForm.GetState(state);
		}
		private static void SetFormState(System.Windows.Forms.Form form, SalFormState state, bool flag)
		{
			ISalForm salForm = form as ISalForm;
			if (salForm == null)
			{
				return;
			}
			salForm.SetState(state, flag);
		}
		internal static bool IsFormClosedOrClosing(System.Windows.Forms.Form form)
		{
			if (form != null)
			{
				if (form.IsDisposed || form.Disposing)
				{
					return true;
				}
				ISalForm salForm = form as ISalForm;
				if (salForm == null)
				{
					return false;
				}
				if (salForm.GetState(SalFormState.Closed) || salForm.GetState(SalFormState.Closing))
				{
					return true;
				}
				if (!form.TopLevel)
				{
					return SalWindow.IsFormClosedOrClosing(form.TopLevelControl as System.Windows.Forms.Form);
				}
			}
			return false;
		}
		internal static bool IsValidating(object control)
		{
			return SalWindow.m_validating == control;
		}
		internal static bool IsValidating()
		{
			return SalWindow.m_validating != null;
		}
		private static void SetDisposed(SalWindow salWnd)
		{
			if (salWnd != null)
			{
				salWnd.m_disposed = true;
			}
		}
		internal static bool IsReadyToDispatch(SalWindow salWnd)
		{
			if (salWnd == null)
			{
				return false;
			}
			if (!salWnd.m_readyToDispatch)
			{
				System.Windows.Forms.Control control = (System.Windows.Forms.Control)salWnd.m_salWnd;
				if (!control.IsHandleCreated)
				{
					return false;
				}
				System.Windows.Forms.Control topLevelControl = control.TopLevelControl;
				if (topLevelControl != null && !topLevelControl.IsHandleCreated)
				{
					return false;
				}
				salWnd.m_readyToDispatch = true;
			}
			return salWnd.m_readyToDispatch;
		}
		
		public static System.Windows.Forms.MdiClient GetMdiClient(System.Windows.Forms.Control ctrl)
		{
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form == null)
			{
				return null;
			}
			if (!form.IsMdiContainer)
			{
				return null;
			}
			return (System.Windows.Forms.MdiClient)SalWindow.FindChild(form, typeof(System.Windows.Forms.MdiClient));
		}
        //internal static void OnRadioButtonChecked(ISalRadioButton btn)
        //{
        //    if (btn == null)
        //    {
        //        return;
        //    }
        //    System.Windows.Forms.Control parent = ((System.Windows.Forms.Control)btn).Parent;
        //    if (parent == null)
        //    {
        //        return;
        //    }
        //    int groupIndex = btn.GroupIndex;
        //    foreach (System.Windows.Forms.Control control in parent.Controls)
        //    {
        //        if (control == btn)
        //        {
        //            control.TabStop = true;
        //        }
        //        else
        //        {
        //            ISalRadioButton salRadioButton = control as ISalRadioButton;
        //            if (salRadioButton != null && groupIndex == salRadioButton.GroupIndex)
        //            {
        //                control.TabStop = false;
        //                salRadioButton.Checked = false;
        //            }
        //        }
        //    }
        //}
		private static System.IntPtr GetSafeHandle(System.Windows.Forms.Control ctrl)
		{
			if (ctrl == null)
			{
				return System.IntPtr.Zero;
			}
			if (ctrl.IsDisposed)
			{
				return System.IntPtr.Zero;
			}
            //SalNativeControl salNativeControl = ctrl as SalNativeControl;
            //if (salNativeControl != null)
            //{
            //    return salNativeControl.Handle;
            //}
			if (ctrl.IsHandleCreated)
			{
				return ctrl.Handle;
			}
			return System.IntPtr.Zero;
		}
        //public static object FromHandle(SalWindowHandle handle, System.Type type)
        //{
        //    //System.Windows.Forms.Control control = SalWindow.TranslateControl(handle.ToControl());
        //    //if (control == null)
        //    //{
        //    //    return null;
        //    //}
        //    object result;
        //    try
        //    {
        //        result = TypeManager.DynamicCast(control, type);
        //    }
        //    catch (System.InvalidCastException e)
        //    {
        //        Sys.TraceException(Sys.TraceWindows, e, TraceLevel.Error);
        //        throw new System.InvalidCastException(string.Format(Sys.GetString("InvalidTypeCast"), control.Name, control.GetType().FullName, type.FullName));
        //    }
        //    return result;
        //}
		public static bool IsSalMessage(int msg)
		{
			if (msg != 563)
			{
				switch (msg)
				{
				case 4103:
				case 4104:
					break;
				default:
					switch (msg)
					{
					case 8193:
					case 8194:
					case 8195:
					case 8196:
					case 8197:
					case 8198:
					case 8199:
					case 8201:
					case 8202:
					case 8203:
					case 8204:
					case 8205:
					case 8206:
					case 8207:
					case 8208:
					case 8209:
					case 8210:
					case 8211:
					case 8212:
					case 8213:
					case 8214:
					case 8215:
					case 8216:
					case 8217:
					case 8218:
					case 8219:
					case 8220:
					case 8221:
					case 8222:
					case 8237:
					case 8238:
					case 8239:
					case 8240:
					case 8241:
					case 8242:
					case 8243:
					case 8244:
					case 8245:
					case 8247:
					case 8248:
					case 8249:
					case 8257:
					case 8264:
					case 8269:
					case 8271:
						return true;
					}
					return false;
				}
			}
			return true;
		}
		public static string GetSalMessageName(int msg)
		{
			int num = msg;
			if (num == 563)
			{
				return "SAM_DropFiles";
			}
			switch (num)
			{
			case 4103:
				return "SAM_SetFocus";
			case 4104:
				return "SAM_KillFocus";
			default:
				switch (num)
				{
				case 8193:
					return "SAM_Create";
				case 8194:
					return "SAM_Destroy";
				case 8195:
					return "SAM_SqlError";
				case 8196:
					return "SAM_AnyEdit";
				case 8197:
					return "SAM_FieldEdit";
				case 8198:
					return "SAM_Click";
				case 8199:
					return "SAM_FetchRow";
				case 8201:
					return "SAM_DoubleClick";
				case 8202:
					return "SAM_ScrollBar";
				case 8203:
					return "SAM_CacheFull";
				case 8204:
					return "SAM_Validate";
				case 8205:
					return "SAM_ReportFetchInit";
				case 8206:
					return "SAM_ReportFetchNext";
				case 8207:
					return "SAM_ReportStart";
				case 8208:
					return "SAM_ReportFinish";
				case 8209:
					return "SAM_CountRows";
				case 8210:
					return "SAM_CaptionDoubleClick";
				case 8211:
					return "SAM_Print";
				case 8212:
					return "SAM_RowHeaderClick";
				case 8213:
					return "SAM_RowHeaderDoubleClick";
				case 8214:
					return "SAM_CornerClick";
				case 8215:
					return "SAM_CornerDoubleClick";
				case 8216:
					return "SAM_EndCellTab";
				case 8217:
					return "SAM_DropDown";
				case 8218:
					return "SAM_FetchDone";
				case 8219:
					return "SAM_ColumnSelectClick";
				case 8220:
					return "SAM_Help";
				case 8221:
					return "SAM_RowValidate";
				case 8222:
					return "SAM_ReportNotify";
				case 8237:
					return "SAM_FetchRowDone";
				case 8238:
					return "SAM_DragStart";
				case 8239:
					return "SAM_DragEnter";
				case 8240:
					return "SAM_DragMove";
				case 8241:
					return "SAM_DragExit";
				case 8242:
					return "SAM_DragDrop";
				case 8243:
					return "SAM_DragCanAutoStart";
				case 8244:
					return "SAM_DragEnd";
				case 8245:
					return "SAM_DragNotify";
				case 8247:
					return "SAM_RowSetContext";
				case 8248:
					return "SAM_CreateComplete";
				case 8249:
					return "SAM_CustControlCmd";
				case 8257:
					return "SAM_Activate";
				case 8264:
					return "SAM_ContextMenu";
				case 8269:
					return "SAM_DockChange";
				case 8271:
					return "SAM_Dock";
				}
				return msg.ToString();
			}
		}
		public static string GetMessageName(int msg)
		{
			if (msg <= 675)
			{
				if (msg <= 564)
				{
					switch (msg)
					{
					case 1:
						return "WM_CREATE";
					case 2:
						return "WM_DESTROY";
					case 3:
						return "WM_MOVE";
					case 4:
					case 9:
					case 37:
					case 41:
					case 52:
					case 53:
					case 54:
					case 56:
					case 58:
					case 59:
					case 60:
					case 61:
					case 62:
					case 63:
					case 64:
					case 66:
					case 67:
					case 68:
					case 69:
					case 73:
					case 76:
					case 77:
					case 79:
					case 86:
					case 87:
					case 88:
					case 89:
					case 90:
					case 91:
					case 92:
					case 93:
					case 94:
					case 95:
					case 96:
					case 97:
					case 98:
					case 99:
					case 100:
					case 101:
					case 102:
					case 103:
					case 104:
					case 105:
					case 106:
					case 107:
					case 108:
					case 109:
					case 110:
					case 111:
					case 112:
					case 113:
					case 114:
					case 115:
					case 116:
					case 117:
					case 118:
					case 119:
					case 120:
					case 121:
					case 122:
					case 136:
					case 137:
					case 138:
					case 139:
					case 140:
					case 141:
					case 142:
					case 143:
					case 144:
					case 145:
					case 146:
					case 147:
					case 148:
					case 149:
					case 150:
					case 151:
					case 152:
					case 153:
					case 154:
					case 155:
					case 156:
					case 157:
					case 158:
					case 159:
						break;
					case 5:
						return "WM_SIZE";
					case 6:
						return "WM_ACTIVATE";
					case 7:
						return "WM_SETFOCUS";
					case 8:
						return "WM_KILLFOCUS";
					case 10:
						return "WM_ENABLE";
					case 11:
						return "WM_SETREDRAW";
					case 12:
						return "WM_SETTEXT";
					case 13:
						return "WM_GETTEXT";
					case 14:
						return "WM_GETTEXTLENGTH";
					case 15:
						return "WM_PAINT";
					case 16:
						return "WM_CLOSE";
					case 17:
						return "WM_QUERYENDSESSION";
					case 18:
						return "WM_QUIT";
					case 19:
						return "WM_QUERYOPEN";
					case 20:
						return "WM_ERASEBKGND";
					case 21:
						return "WM_SYSCOLORCHANGE";
					case 22:
						return "WM_ENDSESSION";
					case 23:
						return "WM_SYSTEMERROR";
					case 24:
						return "WM_SHOWWINDOW";
					case 25:
						return "WM_CTLCOLOR";
					case 26:
						return "WM_WININICHANGE";
					case 27:
						return "WM_DEVMODECHANGE";
					case 28:
						return "WM_ACTIVATEAPP";
					case 29:
						return "WM_FONTCHANGE";
					case 30:
						return "WM_TIMECHANGE";
					case 31:
						return "WM_CANCELMODE";
					case 32:
						return "WM_SETCURSOR";
					case 33:
						return "WM_MOUSEACTIVATE";
					case 34:
						return "WM_CHILDACTIVATE";
					case 35:
						return "WM_QUEUESYNC";
					case 36:
						return "WM_GETMINMAXINFO";
					case 38:
						return "WM_PAINTICON";
					case 39:
						return "WM_ICONERASEBKGND";
					case 40:
						return "WM_NEXTDLGCTL";
					case 42:
						return "WM_SPOOLERSTATUS";
					case 43:
						return "WM_DRAWITEM";
					case 44:
						return "WM_MEASUREITEM";
					case 45:
						return "WM_DELETEITEM";
					case 46:
						return "WM_VKEYTOITEM";
					case 47:
						return "WM_CHARTOITEM";
					case 48:
						return "WM_SETFONT";
					case 49:
						return "WM_GETFONT";
					case 50:
						return "WM_SETHOTKEY";
					case 51:
						return "WM_GETHOTKEY";
					case 55:
						return "WM_QUERYDRAGICON";
					case 57:
						return "WM_COMPAREITEM";
					case 65:
						return "WM_COMPACTING";
					case 70:
						return "WM_WINDOWPOSCHANGING";
					case 71:
						return "WM_WINDOWPOSCHANGED";
					case 72:
						return "WM_POWER";
					case 74:
						return "WM_COPYDATA";
					case 75:
						return "WM_CANCELJOURNAL";
					case 78:
						return "WM_NOTIFY";
					case 80:
						return "WM_INPUTLANGCHANGEREQUEST";
					case 81:
						return "WM_INPUTLANGCHANGE";
					case 82:
						return "WM_TCARD";
					case 83:
						return "WM_HELP";
					case 84:
						return "WM_USERCHANGED";
					case 85:
						return "WM_NOTIFYFORMAT";
					case 123:
						return "WM_CONTEXTMENU";
					case 124:
						return "WM_STYLECHANGING";
					case 125:
						return "WM_STYLECHANGED";
					case 126:
						return "WM_DISPLAYCHANGE";
					case 127:
						return "WM_GETICON";
					case 128:
						return "WM_SETICON";
					case 129:
						return "WM_NCCREATE";
					case 130:
						return "WM_NCDESTROY";
					case 131:
						return "WM_NCCALCSIZE";
					case 132:
						return "WM_NCHITTEST";
					case 133:
						return "WM_NCPAINT";
					case 134:
						return "WM_NCACTIVCATE";
					case 135:
						return "WM_GETDLGCODE";
					case 160:
						return "WM_NCMOUSEMOVE";
					case 161:
						return "WM_NCLBUTTONDOWN";
					case 162:
						return "WM_NCLBUTTONUP";
					case 163:
						return "WM_NCLBUTTONDBLCLK";
					case 164:
						return "WM_NCRBUTTONDOWN";
					case 165:
						return "WM_NCRBUTTONUP";
					case 166:
						return "WM_NCRBUTTONDBLCLK";
					case 167:
						return "WW_NCMBUTTONDOWN";
					case 168:
						return "WM_NCMBUTTONUP";
					case 169:
						return "WM_NCBUTTONDBLCLK";
					default:
						switch (msg)
						{
						case 256:
							return "WM_KEYDOWN";
						case 257:
							return "WM_KEYUP";
						case 258:
							return "WM_CHAR";
						case 259:
							return "WM_DEADCHAR";
						case 260:
							return "WM_SYSKEYDOWN";
						case 261:
							return "WM_SYSKEYUP";
						case 262:
							return "WM_SYSCHAR";
						case 263:
							return "WM_SYSDEADCHAR";
						case 264:
							return "WM_KEYLAST";
						case 265:
						case 266:
						case 267:
						case 268:
						case 280:
						case 281:
						case 282:
						case 283:
						case 284:
						case 285:
						case 286:
						case 290:
						case 291:
						case 292:
						case 293:
						case 294:
						case 295:
						case 296:
						case 297:
						case 298:
						case 299:
						case 300:
						case 301:
						case 302:
						case 303:
						case 304:
						case 305:
							break;
						case 269:
							return "WM_IME_STARTCOMPOSITION";
						case 270:
							return "WM_IME_ENDCOMPOSITION";
						case 271:
							return "WM_IME_COMPOSITION";
						case 272:
							return "WM_INITDIALOG";
						case 273:
							return "WM_COMMAND";
						case 274:
							return "WM_SYSCOMMAND";
						case 275:
							return "WM_TIMER";
						case 276:
							return "WM_HSCROLL";
						case 277:
							return "WM_VSCROLL";
						case 278:
							return "WM_INITMENU";
						case 279:
							return "WM_INITMENUPOPUP";
						case 287:
							return "WM_MENUSELECT";
						case 288:
							return "WM_MENUCHAR";
						case 289:
							return "WM_ENTERIDLE";
						case 306:
							return "WM_CTLCOLORMSGBOX";
						case 307:
							return "WM_CTLCOLOREDIT";
						case 308:
							return "WM_CTRLCOLORLISTBOX";
						case 309:
							return "WM_CTLCOLORBTN";
						case 310:
							return "WM_CTLCOLORDLG";
						case 311:
							return "WM_CTLCOLORSCROLLBAR";
						case 312:
							return "WM_CTLCOLORSTATIC";
						default:
							switch (msg)
							{
							case 512:
								return "WM_MOUSEMOVE";
							case 513:
								return "WM_LBUTTONDOWN";
							case 514:
								return "WM_LBUTTONUP";
							case 515:
								return "WM_LBUTTONDBLCLK";
							case 516:
								return "WM_RBUTTONDOWN";
							case 517:
								return "WM_RBUTTONUP";
							case 518:
								return "WM_RBUTTONDBLCLK";
							case 519:
								return "WM_MBUTTONDOWN";
							case 520:
								return "WM_MBUTTONUP";
							case 521:
								return "WM_MBUTTONDBLCLK";
							case 522:
								return "WM_MOUSEWHEEL";
							case 526:
								return "WM_MOUSEHWEEL";
							case 528:
								return "WM_PARENTNOTIFY";
							case 529:
								return "WM_ENTERMENULOOP";
							case 530:
								return "WM_EXITMENULOOP";
							case 531:
								return "WM_NEXTMENU";
							case 532:
								return "WM_SIZING";
							case 533:
								return "WM_CAPTURECHANGED";
							case 534:
								return "WM_MOVING";
							case 536:
								return "WM_POWERBROADCAST";
							case 537:
								return "WM_DEVICECHANGE";
							case 544:
								return "WM_MDICREATE";
							case 545:
								return "WM_MDIDESTROY";
							case 546:
								return "WM_MDIACTIVATE";
							case 547:
								return "WM_MDIRESTORE";
							case 548:
								return "WM_MDINEXT";
							case 549:
								return "WM_MDIMAXIMIZE";
							case 550:
								return "WM_MDITITLE";
							case 551:
								return "WM_MDICASCADE";
							case 552:
								return "WM_MDIICONARRANGE";
							case 553:
								return "WM_MDIGETACTIVE";
							case 560:
								return "WM_MDISETMENU";
							case 561:
								return "WM_ENTERSIZEMOVE";
							case 562:
								return "WM_EXITSIZEMOVE";
							case 563:
								return "WM_DROPFILES";
							case 564:
								return "WM_MDIREFRESHMENU";
							}
							break;
						}
						break;
					}
				}
				else
				{
					switch (msg)
					{
					case 641:
						return "WM_IME_SETCONTEXT";
					case 642:
						return "WM_IME_NOTIFY";
					case 643:
						return "WM_IME_CONTROL";
					case 644:
						return "WM_IME_COMPOSITIONFULL";
					case 645:
						return "WM_IME_SELECT";
					case 646:
						return "WM_IME_CHAR";
					default:
						switch (msg)
						{
						case 656:
							return "WM_IME_KEYDOWN";
						case 657:
							return "WM_IME_KEYUP";
						default:
							switch (msg)
							{
							case 673:
								return "WM_MOUSEHOVER";
							case 674:
								return "WM_NCMOUSELEAVE";
							case 675:
								return "WM_MOUSELEAVE";
							}
							break;
						}
						break;
					}
				}
			}
			else
			{
				if (msg <= 863)
				{
					switch (msg)
					{
					case 768:
						return "WM_CUT";
					case 769:
						return "WM_COPY";
					case 770:
						return "WM_PASTE";
					case 771:
						return "WM_CLEAR";
					case 772:
						return "WM_UNDO";
					case 773:
						return "WM_RENDERFORMAT";
					case 774:
						return "WM_RENDERALLFORMATS";
					case 775:
						return "WM_DESTROYCLIPBOARD";
					case 776:
						return "WM_DRAWCLIPBOARD";
					case 777:
						return "WM_PAINTCLIPBOARD";
					case 778:
						return "WM_VSCROLLCLIPBOARD";
					case 779:
						return "WM_SIZECLIPBOARD";
					case 780:
						return "WM_ASKCBFORMATNAME";
					case 781:
						return "WM_CHANGECBCHAIN";
					case 782:
						return "WM_HSCROLLCLIPBOARD";
					case 783:
						return "WM_QUERYNEWPALETTE";
					case 784:
						return "WM_PALETTEISCHANGING";
					case 785:
						return "WM_PALETTECHANGED";
					case 786:
						return "WM_HOTKEY";
					case 787:
					case 788:
					case 789:
					case 790:
						break;
					case 791:
						return "WM_PRINT";
					case 792:
						return "WM_PRINTCLIENT";
					default:
						if (msg == 856)
						{
							return "WM_HANDHELDFIRST";
						}
						if (msg == 863)
						{
							return "WM_HANDHELDLAST";
						}
						break;
					}
				}
				else
				{
					if (msg <= 912)
					{
						if (msg == 896)
						{
							return "WM_PENWINFIRST";
						}
						switch (msg)
						{
						case 911:
							return "WM_PENWINLAST";
						case 912:
							return "WM_COALESCE_FIRST";
						}
					}
					else
					{
						if (msg == 927)
						{
							return "WM_COALESCE_LAST";
						}
						switch (msg)
						{
						case 992:
							return "WM_DDE_INITIATE";
						case 993:
							return "WM_DDE_TERMINATE";
						case 994:
							return "WM_DDE_ADVISE";
						case 995:
							return "WM_DDE_UNADVISE";
						case 996:
							return "WM_DDE_ACK";
						case 997:
							return "WM_DDE_DATA";
						case 998:
							return "WM_DDE_REQUEST";
						case 999:
							return "WM_DDE_POKE";
						case 1000:
							return "WM_DDE_EXECUTE";
						}
					}
				}
			}
			return "";
		}
		public static bool IsMouseMessage(int msg)
		{
			return msg >= 512 && msg <= 525;
		}
		public static bool IsKeyboardMessage(int msg)
		{
			return msg >= 256 && msg <= 265;
		}
        //public static bool IsScrollBarVisible(System.Windows.Forms.Control control, System.Windows.Forms.ScrollBars bars)
        //{
        //    if (!control.IsHandleCreated)
        //    {
        //        return false;
        //    }
        //    int windowLong = WinSDK.GetWindowLong(control.Handle, -16);
        //    switch (bars)
        //    {
        //    case System.Windows.Forms.ScrollBars.None:
        //        return (windowLong & 3145728) == 0;
        //    case System.Windows.Forms.ScrollBars.Horizontal:
        //        return (windowLong & 1048576) == 1048576;
        //    case System.Windows.Forms.ScrollBars.Vertical:
        //        return (windowLong & 2097152) == 2097152;
        //    case System.Windows.Forms.ScrollBars.Both:
        //        return (windowLong & 3145728) == 3145728;
        //    default:
        //        return false;
        //    }
        //}
		
        internal static string GetTextWithMask(System.Windows.Forms.Control ctrl)
		{
			string text;
			lock (typeof(SalWindow))
			{
				bool keepMask = SalWindow.KeepMask;
				SalWindow.KeepMask = true;
				try
				{
					text = ctrl.Text;
				}
				finally
				{
					SalWindow.KeepMask = keepMask;
				}
			}
			return text;
		}
		internal static string GetTextWithoutMask(System.Windows.Forms.Control ctrl)
		{
			string text;
			lock (typeof(SalWindow))
			{
				bool keepMask = SalWindow.KeepMask;
				SalWindow.KeepMask = false;
				try
				{
					text = ctrl.Text;
				}
				finally
				{
					SalWindow.KeepMask = keepMask;
				}
			}
			return text;
		}
		internal static byte[] GetKeyboardState()
		{
			byte[] array = new byte[256];
			WinSDK.GetKeyboardState(array);
			return array;
		}
		
		private static bool IsMultiSelect(System.Windows.Forms.SelectionMode selMode)
		{
			return selMode == System.Windows.Forms.SelectionMode.MultiSimple || selMode == System.Windows.Forms.SelectionMode.MultiExtended;
		}
		private static void selTimer_Tick(object sender, System.EventArgs e)
		{
			SalWindow.m_selTimer.Stop();
			SalWindow.m_selBuffer.Length = 0;
		}
		private static System.Exception InvalidFormTemplateError(System.Type t)
		{
			string message = string.Format(Sys.GetString("InvalidFormTemplate"), (t == null) ? "<null>" : t.FullName);
			return new System.ArgumentException(message);
		}
		private static System.Exception UnknownFormTemplateError(string t)
		{
			string message = string.Format(Sys.GetString("UnknownFormTemplate"), (t == null) ? "<null>" : t);
			return new System.ArgumentException(message);
		}
		private static System.Exception WrongNumberOfWindowParameters(System.Type t)
		{
			string message = string.Format(Sys.GetString("WrongNumerOfWindowParams"), t.FullName);
			return new System.ArgumentException(message);
		}
		public static bool CanCut()
		{
			return SalWindow.CanDoClipboardCommand(768);
		}
		public static bool CanCopy()
		{
			return SalWindow.CanDoClipboardCommand(769);
		}
		public static bool CanPaste()
		{
			return SalWindow.CanDoClipboardCommand(770);
		}
		public static bool CanUndo()
		{
			return SalWindow.CanDoClipboardCommand(772);
		}
		public static bool Clear()
		{
			return SalWindow.DoClipboardCommand(771);
		}
		public static bool Copy()
		{
			return SalWindow.DoClipboardCommand(769);
		}
		public static void CopyString(string text)
		{
			try
			{
				System.Windows.Forms.Clipboard.SetDataObject(new System.Windows.Forms.DataObject(System.Windows.Forms.DataFormats.UnicodeText, text));
			}
			catch (System.Exception e)
			{
				Sys.TraceException(Sys.TraceSystem, e, TraceLevel.Error);
			}
		}
		public static bool Cut()
		{
			return SalWindow.DoClipboardCommand(768);
		}
		public static bool Paste()
		{
			return SalWindow.DoClipboardCommand(770);
		}
		public static bool PasteString(ref string text)
		{
			try
			{
				System.Windows.Forms.IDataObject dataObject = System.Windows.Forms.Clipboard.GetDataObject();
				bool result;
				if (dataObject == null)
				{
					result = false;
					return result;
				}
				object data = dataObject.GetData(System.Windows.Forms.DataFormats.UnicodeText, true);
				if (data == null || !(data is string))
				{
					result = false;
					return result;
				}
				text = (data as string);
				result = true;
				return result;
			}
			catch (System.Exception e)
			{
				Sys.TraceException(Sys.TraceWindows, e, TraceLevel.Error);
			}
			return false;
		}
		public static bool Undo()
		{
			return SalWindow.DoClipboardCommand(772);
		}
		
		
		private static bool TestAttributes(int attributes, int mask)
		{
			return (attributes & mask) == mask;
		}
        public static System.Windows.Forms.Control TranslateControl(System.Windows.Forms.Control ctrl)
        {
            if (ctrl == null)
            {
                return null;
            }
            
            ctrl = SalWindow.GetDerivedInstance(ctrl);
            return ctrl;
        }
		public static bool BringToTop(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form == null)
			{
				ctrl.BringToFront();
			}
			else
			{
				if (form.TopLevel || form.IsMdiChild)
				{
					form.Activate();
				}
				else
				{
					form.BringToFront();
				}
			}
			return true;
		}
		public static bool Center(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			System.Windows.Forms.Control control = ctrl.Parent;
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form != null && form.TopLevel)
			{
				control = form.Owner;
				if (control != null && control.TopLevelControl != null)
				{
					control = control.TopLevelControl;
				}
				form.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			}
			Rectangle workingArea = System.Windows.Forms.Screen.FromControl((control != null) ? control : ctrl).WorkingArea;
			Size size = (control != null) ? control.ClientSize : workingArea.Size;
			if (control is System.Windows.Forms.Form && ((System.Windows.Forms.Form)control).Menu != null)
			{
				size.Height -= System.Windows.Forms.SystemInformation.MenuHeight;
			}
			Size size2 = ctrl.Size;
			Point location = new Point((size.Width - size2.Width) / 2, (size.Height - size2.Height) / 2);
			if (control != null)
			{
				if (form != null && form.TopLevel)
				{
					location.Y += control.Top;
					location.X += control.Left;
				}
				if (location.X < workingArea.X)
				{
					location.X = workingArea.X;
				}
				if (location.Y < workingArea.Y)
				{
					location.Y = workingArea.Y;
				}
				if (location.X + ctrl.Width > workingArea.Right)
				{
					location.X = workingArea.Right - ctrl.Width;
				}
				if (location.Y + ctrl.Height > workingArea.Bottom)
				{
					location.Y = workingArea.Bottom - ctrl.Height;
				}
			}
			ctrl.Location = location;
			return true;
		}
		public static bool Clear(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null || ctrl is System.Windows.Forms.Form)
			{
				return false;
			}
			if (SalWindow.IsEditControl(ctrl) || ctrl is System.Windows.Forms.Label)
			{
				ctrl.Text = string.Empty;
			}
			else
			{
				if (ctrl is System.Windows.Forms.CheckBox)
				{
					((System.Windows.Forms.CheckBox)ctrl).Checked = false;
				}
				else
				{
					if (ctrl is System.Windows.Forms.ComboBox)
					{
						((System.Windows.Forms.ComboBox)ctrl).SelectedIndex = -1;
					}
					else
					{
						if (ctrl is System.Windows.Forms.ListBox)
						{
							((System.Windows.Forms.ListBox)ctrl).ClearSelected();
						}
						
					}
				}
			}
			return true;
		}
        //public static System.Windows.Forms.Control CreateWindow(System.Type type, System.Windows.Forms.Control owner, params object[] args)
        //{
        //    owner = SalWindow.TranslateControl(owner);
        //    System.Windows.Forms.Form form = SalWindow.CreateWindowInternal(type, args);
        //    ISalForm salForm = form as ISalForm;
        //    if (salForm != null)
        //    {
        //        salForm.Show(owner);
        //    }
        //    else
        //    {
        //        form.Show(owner);
        //    }
        //    if (form.IsDisposed || form.Disposing)
        //    {
        //        return null;
        //    }
        //    return form;
        //}
        //public static System.Windows.Forms.Control CreateWindow(string typeName, System.Windows.Forms.Control parent, params object[] args)
        //{
        //    return SalWindow.CreateWindow(typeName, parent, System.Reflection.Assembly.GetCallingAssembly(), args);
        //}
        //internal static System.Windows.Forms.Control CreateWindow(string typeName, System.Windows.Forms.Control parent, System.Reflection.Assembly asm, params object[] args)
        //{
        //    System.Type type = SalFunctionalClass.ResolveType(asm, typeName);
        //    if (type == null)
        //    {
        //        throw SalWindow.UnknownFormTemplateError(typeName);
        //    }
        //    return SalWindow.CreateWindow(type, parent, args);
        //}
        //public static System.Windows.Forms.Control CreateWindow(System.Type type, System.Windows.Forms.Control parent, float left, float top, float width, float height, int flags, params object[] args)
        //{
        //    System.Windows.Forms.Form form = null;
        //    parent = SalWindow.TranslateControl(parent);
        //    bool flag = (flags & 4) == 4;
        //    bool flag2 = (flags & 1) == 1;
        //    bool border = (flags & 2) == 2;
        //    if (flag && parent == null)
        //    {
        //        return null;
        //    }
        //    if (flag && typeof(ISalForm).IsAssignableFrom(type) && parent != null)
        //    {
        //        SalWindow.DisableMessages = true;
        //        try
        //        {
        //            form = SalWindow.CreateWindowInternal(type, args);
        //        }
        //        finally
        //        {
        //            if (form.IsHandleCreated)
        //            {
        //                Sys.TraceWarning(Sys.TraceWindows, "Form {0} created the handle during InitializeComponent().", new object[]
        //                {
        //                    form.Name
        //                });
        //            }
        //            SalWindow.DisableMessages = false;
        //        }
        //        if (flag2)
        //        {
        //            ((ISalForm)form).SetState(SalFormState.CreateHidden, true);
        //        }
        //        //((ISalForm)form).ShowAsChild(parent, new RectangleF(left, top, width, height), border);
        //    }
        //    else
        //    {
        //        form = SalWindow.CreateWindowInternal(type, args);
        //        if (flag2)
        //        {
        //            ((ISalForm)form).SetState(SalFormState.CreateHidden, true);
        //        }
        //        ((ISalForm)form).Show(parent);
        //    }
        //    if (form.IsDisposed || form.Disposing)
        //    {
        //        return null;
        //    }
        //    return form;
        //}
        //public static System.Windows.Forms.Control CreateWindow(string typeName, System.Windows.Forms.Control parent, float left, float top, float width, float height, int flags)
        //{
        //    return SalWindow.CreateWindow(typeName, parent, left, top, width, height, flags, System.Reflection.Assembly.GetCallingAssembly());
        //}
        //internal static System.Windows.Forms.Control CreateWindow(string typeName, System.Windows.Forms.Control parent, float left, float top, float width, float height, int flags, System.Reflection.Assembly asm)
        //{
        //    System.Type type = SalFunctionalClass.ResolveType(asm, typeName);
        //    if (type == null)
        //    {
        //        throw SalWindow.UnknownFormTemplateError(typeName);
        //    }
        //    return SalWindow.CreateWindow(type, parent, left, top, width, height, flags, new object[0]);
        //}
		public static bool Destroy(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form != null)
			{
				Sys.TraceInfo(Sys.TraceWindows, "Destroy: Window: Form={0}, Handle={1}", new object[]
				{
					form.Name,
					form.Handle
				});
				if (form is ISalForm)
				{
					if (SalWindow.GetFormState(form, SalFormState.Closed))
					{
						return true;
					}
					SalWindow.SetFormState(form, SalFormState.Closed, true);
					if (SalWindow.GetFormState(form, SalFormState.Creating))
					{
						SalWindow.PostMessage(form, 16, System.IntPtr.Zero, System.IntPtr.Zero);
						return true;
					}
				}
				form.Close();
			}
			else
			{
				ctrl.Dispose();
			}
			return true;
		}
		public static bool DisableWindow(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			
			else
			{
				ctrl.Enabled = false;
			}
			return true;
		}
		public static bool DisableWindowAndLabel(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			bool result = SalWindow.DisableWindow(ctrl);
			System.Windows.Forms.Control label = SalWindow.GetLabel(ctrl);
			if (label != null)
			{
				label.Enabled = false;
			}
			return result;
		}
		public static bool EnableWindow(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null || ctrl.IsDisposed)
			{
				return false;
			}
			
			{
				ctrl.Enabled = true;
				if (ctrl is System.Windows.Forms.TextBoxBase)
				{
					((System.Windows.Forms.TextBoxBase)ctrl).ReadOnly = false;
				}
				System.IntPtr safeHandle = SalWindow.GetSafeHandle(ctrl);
				if (safeHandle != System.IntPtr.Zero)
				{
					int windowLong = WinSDK.GetWindowLong(safeHandle, -16);
					if ((windowLong & 134217728) == 134217728)
					{
						if (ctrl is System.Windows.Forms.RadioButton)
						{
							ctrl.TabStop = ((System.Windows.Forms.RadioButton)ctrl).Checked;
						}
						else
						{
							ctrl.TabStop = true;
						}
						WinSDK.SetWindowLong(safeHandle, -16, windowLong & -134217729);
					}
				}
			}
			return true;
		}
		public static bool EnableWindowAndLabel(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			bool result = SalWindow.EnableWindow(ctrl);
			System.Windows.Forms.Control label = SalWindow.GetLabel(ctrl);
			if (label != null)
			{
				label.Enabled = true;
			}
			return result;
		}
		public static bool EndDialog(System.Windows.Forms.Control ctrl, int value)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form == null)
			{
				return false;
			}
			if (!form.Modal)
			{
				return false;
			}
			Sys.TraceInfo(Sys.TraceWindows, "Close: Dialog: Dialog={0}, Handle={1}", new object[]
			{
				form.Name,
				form.Handle
			});
			if (!(form is ISalForm))
			{
				form.DialogResult = (System.Windows.Forms.DialogResult)value;
				form.Close();
				return true;
			}
			if (SalWindow.GetFormState(form, SalFormState.Closed))
			{
				return false;
			}
			SalWindow.SetFormState(form, SalFormState.Closed, true);
			((ISalForm)form).ReturnValue = value;
			if (SalWindow.GetFormState(form, SalFormState.Creating))
			{
				form.Hide();
				SalWindow.PostMessage(form, 16, System.IntPtr.Zero, System.IntPtr.Zero);
			}
			else
			{
				form.Close();
			}
			return true;
		}
		
		public static System.Windows.Forms.Control FindChild(System.Windows.Forms.Control ctrl, string name)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return null;
			}
			return SalWindow.FindChildInternal(ctrl, name, null, true);
		}
		public static System.Windows.Forms.Control FindChild(System.Windows.Forms.Control ctrl, System.Type type)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return null;
			}
			return SalWindow.FindChildInternal(ctrl, null, type, true);
		}
		internal static System.Windows.Forms.Control FindChildInternal(System.Windows.Forms.Control ctrl, string name, System.Type type, bool drillDown)
		{
			if (!ctrl.HasChildren)
			{
				return null;
			}
			foreach (System.Windows.Forms.Control control in ctrl.Controls)
			{
				if (control != null)
				{
					if (name != null && control.Name == name)
					{
						System.Windows.Forms.Control result = control;
						return result;
					}
					if (type != null && type.IsInstanceOfType(control))
					{
						System.Windows.Forms.Control result = control;
						return result;
					}
					if (drillDown)
					{
						System.Windows.Forms.Control control2 = SalWindow.FindChildInternal(control, name, type, true);
						if (control2 != null)
						{
							System.Windows.Forms.Control result = control2;
							return result;
						}
					}
				}
			}
			return null;
		}
		public static System.Windows.Forms.Control GetDefaultButton(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form == null)
			{
				return null;
			}
			return form.AcceptButton as System.Windows.Forms.Control;
		}
		
		
		
		
		
		
		
		private static bool IsControlOfType(System.Windows.Forms.Control ctrl, int typeMask)
		{
			if (ctrl == null)
			{
				return false;
			}
			int controlTypeInternal = SalWindow.GetControlTypeInternal(ctrl);
			return (controlTypeInternal & typeMask) != 0 || (controlTypeInternal == 0 && typeMask == 2147483647);
		}
		public static SalWindowHandle GetFocus()
		{
			return SalWindow.TranslateFocus(WinSDK.GetFocus());
		}
		public static string GetControlName(System.Windows.Forms.Control ctrl)
		{
			SalString x = "";
			SalWindow.GetControlName(ctrl, ref x);
			return x;
		}
		public static bool GetControlName(System.Windows.Forms.Control ctrl, ref SalString sName)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			int controlType = SalWindow.GetControlType(ctrl);
			if (controlType <= 2048)
			{
				if (controlType != 256 && controlType != 2048)
				{
					goto IL_47;
				}
			}
			else
			{
				if (controlType != 32768 && controlType != 65536)
				{
					goto IL_47;
				}
			}
			sName = SalString.Empty;
			return false;
			IL_47:
			sName = ctrl.Name;
			return true;
		}
		public static string GetLabelText(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return null;
			}
			System.Windows.Forms.Control label = SalWindow.GetLabel(ctrl);
			if (label == null)
			{
				return string.Empty;
			}
			return label.Text;
		}
		public static string GetLabelText(System.Windows.Forms.Control ctrl, int maxLen)
		{
			SalString salString = SalWindow.GetLabelText(ctrl);
			return salString.Left(maxLen);
		}
		public static SalNumber GetLabelText(System.Windows.Forms.Control ctrl, ref SalString sText, int maxLen)
		{
			SalString salString = SalWindow.GetLabelText(ctrl);
			if (salString.IsNull)
			{
				return 0;
			}
			sText = salString.Left(maxLen);
			return sText.Length;
		}
		
		
		public static int GetState(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return 1;
			}
			if (!ctrl.Visible)
			{
				return 2;
			}
			if (!(ctrl is System.Windows.Forms.Form))
			{
				return 5;
			}
			switch (((System.Windows.Forms.Form)ctrl).WindowState)
			{
			case System.Windows.Forms.FormWindowState.Minimized:
				return 4;
			case System.Windows.Forms.FormWindowState.Maximized:
				return 3;
			default:
				return 5;
			}
		}
		public static string GetText(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return null;
			}
			return SalWindow.GetTextWithMask(ctrl);
		}
		public static int GetText(System.Windows.Forms.Control ctrl, ref SalString text, int maxLen)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return 0;
			}
			ISalControl salControl = ctrl as ISalControl;
			if (salControl == null || salControl.GetDataType() != 7)
			{
				text = SalWindow.GetTextWithMask(ctrl);
				text = text.Left(maxLen);
				return text.Length;
			}
			text = (SalString)salControl.Value;
			if (!text.IsNull)
			{
				return text.Value.Length;
			}
			return 0;
		}
		public static SalString GetText(System.Windows.Forms.Control ctrl, int maxLen)
		{
			SalString result = "";
			SalWindow.GetText(ctrl, ref result, maxLen);
			return result;
		}
		public static bool HideWindow(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			bool result;
			
			{
				result = ctrl.Visible;
				ctrl.Hide();
			}
			return result;
		}
		public static bool HideWindowAndLabel(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			bool result = SalWindow.HideWindow(ctrl);
			System.Windows.Forms.Control label = SalWindow.GetLabel(ctrl);
			if (label != null)
			{
				label.Hide();
			}
			return result;
		}
		public static bool Invalidate(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			
			{
				ctrl.Invalidate(true);
			}
			return true;
		}
		public static bool IsChecked(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl is System.Windows.Forms.CheckBox)
			{
				return ((System.Windows.Forms.CheckBox)ctrl).Checked;
			}
			return ctrl is System.Windows.Forms.RadioButton && ((System.Windows.Forms.RadioButton)ctrl).Checked;
		}
		public static bool IsEnabled(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			
			System.IntPtr safeHandle = SalWindow.GetSafeHandle(ctrl);
			if (safeHandle == System.IntPtr.Zero)
			{
				return ctrl.Enabled;
			}
			return WinSDK.IsWindowEnabled(safeHandle);
		}
		public static bool IsVisible(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			
			System.IntPtr safeHandle = SalWindow.GetSafeHandle(ctrl);
			if (safeHandle == System.IntPtr.Zero)
			{
				return ctrl.Visible;
			}
			return WinSDK.IsWindowVisible(safeHandle);
		}
		public static bool MessageBeep(int alert)
		{
			return WinSDK.MessageBeep(alert);
		}
		public static int MessageBox(System.Windows.Forms.Control owner, string text, string title, int flags)
		{
			System.Windows.Forms.Form form = (owner != null) ? owner.FindForm() : null;
			if (form != null && System.Diagnostics.Debugger.IsAttached && form.GetType().Name == "ParkingWindow")
			{
				form = null;
			}
			System.IntPtr focus = WinSDK.GetFocus();
			int result;
			try
			{
				System.Windows.Forms.MessageBoxButtons buttons = (System.Windows.Forms.MessageBoxButtons)(flags & 15);
				System.Windows.Forms.MessageBoxIcon icon = (System.Windows.Forms.MessageBoxIcon)(flags & 240);
				System.Windows.Forms.MessageBoxDefaultButton defaultButton = (System.Windows.Forms.MessageBoxDefaultButton)(flags & 768);
				System.Windows.Forms.MessageBoxOptions options = (System.Windows.Forms.MessageBoxOptions)(flags & 3801088);
				result = (int)System.Windows.Forms.MessageBox.Show(form, text, title, buttons, icon, defaultButton, options);
			}
			finally
			{
				if (form != null)
				{
					form.Update();
					if (!SalWindow.IsValidating())
					{
						WinSDK.SetFocus(focus);
					}
				}
			}
			return result;
		}
        //public static int ModalDialog(System.Type type, System.Windows.Forms.Control owner, params object[] args)
        //{
        //    owner = SalWindow.TranslateControl(owner);
			
        //    ISalForm salForm = (ISalForm)SalWindow.CreateWindowInternal(type, args);
        //    return salForm.ShowDialog(owner);
        //}
        //public static int ModalDialog(string typeName, System.Windows.Forms.Control owner, params object[] args)
        //{
        //    return SalWindow.ModalDialog(typeName, owner, System.Reflection.Assembly.GetCallingAssembly(), args);
        //}
        //internal static int ModalDialog(string typeName, System.Windows.Forms.Control owner, System.Reflection.Assembly asm, params object[] args)
        //{
        //    System.Type type = SalFunctionalClass.ResolveType(asm, typeName);
        //    if (type == null)
        //    {
        //        throw SalWindow.UnknownFormTemplateError(typeName);
        //    }
        //    return SalWindow.ModalDialog(type, owner, args);
        //}
		
		public static System.Windows.Forms.Control GetParent(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return null;
			}
			System.Windows.Forms.Control control = ctrl.Parent;
			if (control == null && ctrl is System.Windows.Forms.Form)
			{
				control = ((System.Windows.Forms.Form)ctrl).Owner;
				if (control == null && ctrl.Disposing && ctrl is ISalForm)
				{
					control = ((ISalForm)ctrl).SavedOwner;
				}
			}
			if (control == null)
			{
				return null;
			}
			
			return control.FindForm();
		}
		public static bool PostMessage(System.Windows.Forms.Control ctrl, int msg, System.IntPtr wParam, System.IntPtr lParam)
		{
			if (SalWindow.enablePostMessageQueueing && !SalWindow.forceNativePostMessageHandling)
			{
				SalWindow.postMessageQueue.Enqueue(new SalWindow.PostMessageQueueItem(ctrl, msg, (int)wParam, (int)lParam));
				return true;
			}
			SalWindow.forceNativePostMessageHandling = false;
			ctrl = SalWindow.TranslateControl(ctrl);
			return ctrl != null && !ctrl.IsDisposed && WinSDK.PostMessage(SalWindow.GetSafeHandle(ctrl), msg, wParam, lParam) != System.IntPtr.Zero;
		}
		public static SalNumber SendMessage(System.Windows.Forms.Control ctrl, int msg, SalNumber wParam, SalNumber lParam)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null || ctrl.IsDisposed)
			{
				return System.IntPtr.Zero;
			}
			return WinSDK.SendMessage(SalWindow.GetSafeHandle(ctrl), msg, wParam, lParam);
		}
        //public static bool SendMessageToChildren(System.Windows.Forms.Control ctrl, int msg, SalNumber wParam, SalNumber lParam)
        //{
        //    ctrl = SalWindow.TranslateControl(ctrl);
        //    return ctrl != null && !ctrl.IsDisposed && SalWindow.SendMessageToChildrenInternal(ctrl, msg, wParam, lParam);
        //}
        //public static bool SendMessageToChildrenInternal(System.Windows.Forms.Control ctrl, int msg, SalNumber wParam, SalNumber lParam)
        //{
        //    System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
        //    if (form != null && form.IsMdiContainer)
        //    {
        //        System.Windows.Forms.Form[] mdiChildren = form.MdiChildren;
        //        for (int i = 0; i < mdiChildren.Length; i++)
        //        {
        //            System.Windows.Forms.Form form2 = mdiChildren[i];
        //            if (form2 != null && !form2.IsDisposed && form2.IsHandleCreated)
        //            {
        //                WinSDK.SendMessage(form2.Handle, msg, wParam, lParam);
        //            }
        //        }
        //    }
        //    bool flag = msg == 2 || msg == 16;
        //    if (ctrl.HasChildren)
        //    {
        //        bool flag2 = ctrl is System.Windows.Forms.MdiClient;
        //        System.Collections.IList sortedControls = SalWindow.GetSortedControls(ctrl);
        //        foreach (System.Windows.Forms.Control control in sortedControls)
        //        {
        //            if (control != null && !control.IsDisposed)
        //            {
        //                if (control.IsHandleCreated)
        //                {
        //                    if (control is System.Windows.Forms.MdiClient || (flag2 && control is System.Windows.Forms.Form))
        //                    {
        //                        continue;
        //                    }
        //                    if (flag)
        //                    {
        //                        SalWindow.FireWindowActions(control, msg, wParam, lParam);
        //                    }
        //                    else
        //                    {
        //                        WinSDK.SendMessage(control.Handle, msg, wParam, lParam);
        //                    }
        //                }
        //                if (!(control is System.Windows.Forms.Form) && !(control is System.Windows.Forms.UserControl))
        //                {
        //                    SalWindow.SendMessageToChildrenInternal(control, msg, wParam, lParam);
        //                }
        //            }
        //        }
        //    }
        //    return true;
        //}
		public static int SendValidateMessage()
		{
			if (SalWindow.m_inSendValidateMsg)
			{
				return 1;
			}
			SalWindow.m_inSendValidateMsg = true;
			int result;
			try
			{
				result = SalWindow.SendValidateMessage(null);
			}
			finally
			{
				SalWindow.m_inSendValidateMsg = false;
			}
			return result;
		}
		internal static int SendValidateMessage(System.Windows.Forms.Control target)
		{
			System.Windows.Forms.Control focus = SalWindow.GetFocus().ToControl();
			return SalWindow.SendValidateMessage(focus, target);
		}
		internal static int SendValidateMessage(System.Windows.Forms.Control focus, System.Windows.Forms.Control target)
		{
			if (focus == null)
			{
				return 1;
			}
			if (SalWindow.IsValidating(focus))
			{
				return 1;
			}
			int wParam = (int)SalWindow.GetSafeHandle(SalWindow.TranslateControl(target));
			
			return SalWindow.ValidateInternal(focus, wParam, 0, false);
		}
		private static void SendSamFieldEdit(System.Windows.Forms.Control ctrl)
		{
			
			SalWindow.FireWindowActions(ctrl, 8197, 0, 0);
		}
		public static bool SetDefaultButton(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Windows.Forms.ButtonBase buttonBase = ctrl as System.Windows.Forms.ButtonBase;
			if (buttonBase == null)
			{
				return false;
			}
			System.Windows.Forms.Form form = ctrl.FindForm();
			if (form == null)
			{
				return false;
			}
			form.AcceptButton = (System.Windows.Forms.IButtonControl)buttonBase;
			return true;
		}
		public static bool SetLabelText(System.Windows.Forms.Control ctrl, string text)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			System.Windows.Forms.Control label = SalWindow.GetLabel(ctrl);
			if (label == null)
			{
				return false;
			}
			label.Text = text;
			return true;
		}
		
		public static bool SetText(System.Windows.Forms.Control ctrl, string text)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			if (ctrl is System.Windows.Forms.ComboBox && text != null && text.Length == 0)
			{
				text = null;
			}
			ctrl.Text = text;
			return true;
		}
		public static bool ShowWindow(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			bool result;
			
			{
				result = ctrl.Visible;
				ctrl.Show();
			}
			return result;
		}
		public static bool ShowWindowAndLabel(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			bool result = SalWindow.ShowWindow(ctrl);
			System.Windows.Forms.Control label = SalWindow.GetLabel(ctrl);
			if (label != null)
			{
				label.Show();
			}
			return result;
		}
		public static bool KillTimer(System.Windows.Forms.Control ctrl, int id)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			return ctrl != null && WinSDK.KillTimer(SalWindow.GetSafeHandle(ctrl), (System.IntPtr)id);
		}
		public static bool SetTimer(System.Windows.Forms.Control ctrl, int id, int millisec)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			return ctrl != null && WinSDK.SetTimer(SalWindow.GetSafeHandle(ctrl), (System.IntPtr)id, millisec, System.IntPtr.Zero) != System.IntPtr.Zero;
		}
		public static bool Update(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			ctrl.Update();
			return true;
		}
		public static string GetClassName(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			
			System.Type type = ctrl.GetType();
			if (ctrl is System.Windows.Forms.Form)
			{
				type = type.BaseType;
			}
			
			if (type.Assembly == System.Reflection.Assembly.GetExecutingAssembly())
			{
				return string.Empty;
			}
			return type.Name;
		}
		
		
		public static bool IsDerivedFrom(System.Windows.Forms.Control ctrl, System.Type type)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			return ctrl != null && TypeManager.IsDerivedFrom(ctrl.GetType(), type);
		}
		internal static SalNumber SendClassMessage(int msg, SalNumber wParam, SalNumber lParam, System.Type startType)
		{
			SalContext current = SalContext.Current;
			System.Windows.Forms.Control control = current.Control;
			ISalWindow salWindow = control as ISalWindow;
			if (control == null || salWindow == null)
			{
				return SalNumber.Zero;
			}
			SalWindow salWindowImpl = salWindow.GetSalWindowImpl();
			if (salWindowImpl.ShouldDispatch(msg))
			{
				int windowActionsIndex = current.WindowActionsIndex;
				WindowActionsEventArgs windowActionsEventArgs = new WindowActionsEventArgs(control, msg, wParam, lParam);
				if (windowActionsIndex > -1)
				{
					if (windowActionsIndex > 0)
					{
						salWindowImpl.InvokeWindowActions(windowActionsEventArgs, current, windowActionsIndex - 1, null);
					}
				}
				else
				{
					if (startType != null)
					{
						System.Collections.Generic.List<System.Delegate> actionsHandlers = SalWindow.GetActionsHandlers(salWindow);
						for (int i = actionsHandlers.Count - 1; i > -1; i--)
						{
							System.Type declaringType = actionsHandlers[i].Method.DeclaringType;
							if (declaringType != startType && TypeManager.IsDerivedFrom(startType, declaringType))
							{
								salWindowImpl.InvokeWindowActions(windowActionsEventArgs, current, i, null);
								break;
							}
						}
					}
				}
				if (windowActionsEventArgs.Handled)
				{
					if (windowActionsEventArgs.HasReturnValue)
					{
						return windowActionsEventArgs.Return;
					}
					return 2147483647;
				}
				else
				{
					Sys.TraceWarning(Sys.TraceWindows, "Message {0} dispatched by SalSendClassMessage was not handled.", new object[]
					{
						SalWindow.GetSalMessageName(msg)
					});
				}
			}
			return 0;
		}
		internal static SalNumber SendClassMessageNamed(int msg, SalNumber wParam, SalNumber lParam, System.Type target)
		{
			SalContext current = SalContext.Current;
			System.Windows.Forms.Control control = current.Control;
			ISalWindow salWindow = control as ISalWindow;
			if (control == null || salWindow == null)
			{
				return SalNumber.Zero;
			}
			SalWindow salWindowImpl = salWindow.GetSalWindowImpl();
			if (salWindowImpl.ShouldDispatch(msg))
			{
				WindowActionsEventArgs windowActionsEventArgs = new WindowActionsEventArgs(control, msg, wParam, lParam);
				System.Collections.Generic.List<System.Delegate> actionsHandlers = SalWindow.GetActionsHandlers(salWindow);
				for (int i = actionsHandlers.Count - 1; i > -1; i--)
				{
					System.Type arg_70_0 = actionsHandlers[i].Method.DeclaringType;
					if (actionsHandlers[i].Method.DeclaringType.IsAssignableFrom(target))
					{
						salWindowImpl.InvokeWindowActions(windowActionsEventArgs, current, i, target);
						if (windowActionsEventArgs.Handled)
						{
							break;
						}
					}
				}
				if (!windowActionsEventArgs.Handled)
				{
					salWindowImpl.InvokeWindowActions(windowActionsEventArgs, current, -1, target);
				}
				if (windowActionsEventArgs.Handled)
				{
					if (windowActionsEventArgs.HasReturnValue)
					{
						return windowActionsEventArgs.Return;
					}
					return 2147483647;
				}
			}
			Sys.TraceWarning(Sys.TraceWindows, "Message {0} dispatched by SalSendClassMessageNamed to {1} was not handled.", new object[]
			{
				SalWindow.GetSalMessageName(msg),
				target.FullName
			});
			return 0;
		}
		public static bool WinHelp(System.Windows.Forms.Control ctrl, string file, int command, int index, string key)
		{
			if (file == null || file.Length == 0)
			{
				return false;
			}
			ctrl = SalWindow.TranslateControl(ctrl);
			System.IntPtr safeHandle = SalWindow.GetSafeHandle(ctrl);
			if (command == 1 || command == 5)
			{
				return WinSDK.WinHelp(safeHandle, file, command, index);
			}
			if (command != 257)
			{
				return WinSDK.WinHelp(safeHandle, file, command, 0);
			}
			return WinSDK.WinHelp(safeHandle, file, command, key);
		}
		public static void Yield(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null || !ctrl.IsHandleCreated)
			{
				System.Windows.Forms.Application.DoEvents();
				return;
			}
			System.IntPtr handle = ctrl.Handle;
			WinSDK.MSG mSG;
			if (WinSDK.PeekMessage(out mSG, handle, 0u, 0u, 1u))
			{
				if (mSG.message == 18u)
				{
					//Sal.Quit();
					return;
				}
				WinSDK.TranslateMessage(ref mSG);
				WinSDK.DispatchMessage(ref mSG);
			}
		}
		
		public static int GetSysColor(int colorValue)
		{
			Color c = Color.Empty;
			if (colorValue != 268435456)
			{
				if (colorValue != 536870912)
				{
					if (colorValue != 1342177280)
					{
						c = ColorTranslator.FromWin32(-2147483648 + colorValue);
					}
					else
					{
						c = SystemColors.WindowFrame;
					}
				}
				else
				{
					c = SystemColors.WindowText;
				}
			}
			else
			{
				c = SystemColors.Window;
			}
			return ColorTranslator.ToWin32(c);
		}
		public static Color TranslateSalColor(int colorValue)
		{
			Color result = Color.Empty;
			if (colorValue <= 536870912)
			{
				if (colorValue <= -1879048192)
				{
					if (colorValue == -2147483648)
					{
						result = SystemColors.ControlDarkDark;
						return result;
					}
					if (colorValue == -1879048192)
					{
						result = SystemColors.ControlLightLight;
						return result;
					}
				}
				else
				{
					if (colorValue == 268435456)
					{
						result = SystemColors.Window;
						return result;
					}
					if (colorValue == 536870912)
					{
						result = SystemColors.WindowText;
						return result;
					}
				}
			}
			else
			{
				if (colorValue <= 1342177280)
				{
					if (colorValue == 805306368)
					{
						result = Color.Empty;
						return result;
					}
					if (colorValue == 1342177280)
					{
						result = SystemColors.WindowFrame;
						return result;
					}
				}
				else
				{
					if (colorValue == 1610612736)
					{
						result = Color.Transparent;
						return result;
					}
					if (colorValue == 1879048192)
					{
						result = SystemColors.Control;
						return result;
					}
				}
			}
			result = ColorTranslator.FromWin32(colorValue);
			return result;
		}
		public static int TranslateColor(Color color)
		{
			if (color.IsEmpty)
			{
				return 805306368;
			}
			if (color == SystemColors.Window)
			{
				return 268435456;
			}
			if (color == SystemColors.WindowText)
			{
				return 536870912;
			}
			if (color == SystemColors.WindowFrame)
			{
				return 1342177280;
			}
			if (color == SystemColors.Control)
			{
				return 1879048192;
			}
			if (color == SystemColors.ControlLightLight)
			{
				return -1879048192;
			}
			if (color == SystemColors.ControlDarkDark)
			{
				return -2147483648;
			}
			if (color == Color.Transparent)
			{
				return 1610612736;
			}
			return ColorTranslator.ToWin32(color);
		}
		
		
		
		public static bool SetCursor(System.Windows.Forms.Control ctrl, System.Windows.Forms.Cursor cursor, int type)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			SalWindow.DisableMessages = true;
			bool result;
			try
			{
				SalWindow salWindow = ctrl;
				switch (type)
				{
				case 1:
					ctrl.Cursor = cursor;
					result = true;
					break;
				case 2:
					if (salWindow == null)
					{
						result = false;
					}
					else
					{
						salWindow.DragDropCursor = cursor;
						result = true;
					}
					break;
				case 3:
					if (salWindow == null)
					{
						result = false;
					}
					else
					{
						salWindow.DisableDropCursor = cursor;
						result = true;
					}
					break;
				default:
					result = false;
					break;
				}
			}
			finally
			{
				SalWindow.DisableMessages = false;
			}
			return result;
		}
		public static bool SetCursor(System.Windows.Forms.Control ctrl, int cursorId, int type)
		{
			if (ctrl == null)
			{
				return false;
			}
			System.Windows.Forms.Cursor cursor;
			switch (cursorId)
			{
			case 32512:
				cursor = System.Windows.Forms.Cursors.Arrow;
				break;
			case 32513:
				cursor = System.Windows.Forms.Cursors.IBeam;
				break;
			case 32514:
				cursor = System.Windows.Forms.Cursors.WaitCursor;
				break;
			case 32515:
				cursor = System.Windows.Forms.Cursors.Cross;
				break;
			case 32516:
				cursor = System.Windows.Forms.Cursors.UpArrow;
				break;
			default:
				switch (cursorId)
				{
				case 32640:
					cursor = System.Windows.Forms.Cursors.SizeAll;
					break;
				case 32641:
					cursor = new System.Windows.Forms.Cursor(new System.IntPtr(32641));
					break;
				case 32642:
					cursor = System.Windows.Forms.Cursors.SizeNWSE;
					break;
				case 32643:
					cursor = System.Windows.Forms.Cursors.SizeNESW;
					break;
				case 32644:
					cursor = System.Windows.Forms.Cursors.SizeWE;
					break;
				case 32645:
					cursor = System.Windows.Forms.Cursors.SizeNS;
					break;
				default:
					cursor = new System.Windows.Forms.Cursor(new System.IntPtr(cursorId));
					break;
				}
				break;
			}
			return SalWindow.SetCursor(ctrl, cursor, type);
		}
		public static bool SetCursor(System.Windows.Forms.Control ctrl, string fileName, int type)
		{
			if (ctrl == null)
			{
				return false;
			}
			bool result;
			try
			{
				result = SalWindow.SetCursor(ctrl, new System.Windows.Forms.Cursor(fileName), type);
			}
			catch (System.Exception e)
			{
				Sys.TraceException(Sys.TraceWindows, e, TraceLevel.Error);
				result = false;
			}
			return result;
		}
		public static bool SetCursor(System.Windows.Forms.Control ctrl, byte[] blob, int type)
		{
			if (ctrl == null)
			{
				return false;
			}
			bool result;
			try
			{
				result = SalWindow.SetCursor(ctrl, new System.Windows.Forms.Cursor(new System.IO.MemoryStream(blob)), type);
			}
			catch (System.Exception e)
			{
				Sys.TraceException(Sys.TraceWindows, e, TraceLevel.Error);
				result = false;
			}
			return result;
		}
		public static bool ClearCursor(System.Windows.Forms.Control ctrl, int type)
		{
			return SalWindow.SetCursor(ctrl, System.Windows.Forms.Cursors.Default, type);
		}
		public static bool WaitCursor(bool wait)
		{
			if (wait)
			{
				System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
			}
			else
			{
				System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
			}
			return true;
		}
		internal static bool DialogChooseColor(System.Windows.Forms.Control owner, ref int color)
		{
			owner = SalWindow.TranslateControl(owner);
			using (System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog())
			{
				colorDialog.FullOpen = true;
				colorDialog.CustomColors = SalWindow.m_customColors;
				if (colorDialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK)
				{
					return false;
				}
				SalWindow.m_customColors = colorDialog.CustomColors;
				color = ColorTranslator.ToWin32(colorDialog.Color);
			}
			return true;
		}
		internal static bool DialogChooseFont(System.Windows.Forms.Control owner, ref string name, ref float size, ref int enhancement, ref int color)
		{
			owner = SalWindow.TranslateControl(owner);
			using (System.Windows.Forms.FontDialog fontDialog = new System.Windows.Forms.FontDialog())
			{
				fontDialog.ShowHelp = true;
				fontDialog.ShowColor = true;
				fontDialog.ShowEffects = true;
				if (fontDialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK)
				{
					return false;
				}
				Font font = fontDialog.Font;
				name = font.Name;
				size = font.SizeInPoints;
				enhancement = ((font.Bold ? 8 : 0) | (font.Italic ? 2 : 0) | (font.Strikeout ? 16 : 0) | (font.Underline ? 4 : 0));
				color = ColorTranslator.ToWin32(fontDialog.Color);
			}
			return true;
		}
		internal static bool DialogOpenFile(System.Windows.Forms.Control owner, string title, string filter, int filterIndex, string initialFileName, string initialFilePath, ref string selectedFile, ref int selectedIndex)
		{
			owner = SalWindow.TranslateControl(owner);
			using (System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog())
			{
				openFileDialog.Title = title;
				openFileDialog.Filter = filter;
				openFileDialog.FilterIndex = filterIndex;
				openFileDialog.FileName = System.IO.Path.GetFileName(initialFileName);
				if (initialFilePath != string.Empty)
				{
					if (System.IO.Directory.Exists(initialFilePath))
					{
						openFileDialog.InitialDirectory = initialFilePath;
					}
					else
					{
						try
						{
							openFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(initialFilePath);
						}
						catch
						{
							openFileDialog.InitialDirectory = "";
						}
					}
				}
				if (openFileDialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK)
				{
					return false;
				}
				selectedFile = openFileDialog.FileName;
				selectedIndex = openFileDialog.FilterIndex;
			}
			return true;
		}
		internal static bool DialogSaveFile(System.Windows.Forms.Control owner, string title, string filter, int filterIndex, string initialFileName, string initialFilePath, ref string selectedFile, ref int selectedIndex)
		{
			owner = SalWindow.TranslateControl(owner);
			using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog())
			{
				saveFileDialog.Title = title;
				saveFileDialog.Filter = filter;
				saveFileDialog.FilterIndex = filterIndex;
				saveFileDialog.CheckFileExists = false;
				saveFileDialog.FileName = System.IO.Path.GetFileName(initialFileName);
				saveFileDialog.InitialDirectory = ((initialFilePath != string.Empty) ? System.IO.Path.GetDirectoryName(initialFilePath) : string.Empty);
				if (saveFileDialog.ShowDialog(owner) != System.Windows.Forms.DialogResult.OK)
				{
					return false;
				}
				selectedFile = saveFileDialog.FileName;
				selectedIndex = saveFileDialog.FilterIndex;
			}
			return true;
		}
		public static bool DragAcceptFiles(System.Windows.Forms.Control ctrl, bool accept)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null || !ctrl.IsHandleCreated)
			{
				return false;
			}
			SalWindow.SetDragAcceptFiles(ctrl, accept);
			return true;
		}
		private System.Windows.Forms.Control FindDropFilesTarget()
		{
			for (System.Windows.Forms.Control control = (System.Windows.Forms.Control)this.m_salWnd; control != null; control = control.Parent)
			{
				if (SalWindow.GetDragAcceptFiles(control))
				{
					return control;
				}
			}
			return null;
		}
		private static void SetDragAcceptFiles(System.Windows.Forms.Control ctrl, bool accept)
		{
			SalWindow salWindow = ctrl;
			if (salWindow == null)
			{
				return;
			}
			salWindow.m_dragAcceptFiles = accept;
		}
		private static bool GetDragAcceptFiles(System.Windows.Forms.Control ctrl)
		{
			SalWindow salWindow = ctrl;
			return salWindow != null && salWindow.m_dragAcceptFiles;
		}
		public static bool SetModified(System.Windows.Forms.Control ctrl, bool modified)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalControl salControl = ctrl as ISalControl;
			if (salControl == null)
			{
				return false;
			}
			salControl.Modified = modified;
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl != null)
			{
				salEditControl.Validated = false;
			}
			return true;
		}
		public static System.Windows.Forms.Control SetFocus(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return null;
			}
			
			if (!SalWindow.IsEnabled(ctrl) || !SalWindow.IsVisible(ctrl))
			{
				return null;
			}
			if (SalWindow.m_validating != null)
			{
				SalWindow.SetFocusAsync(ctrl);
				return SalWindow.GetFocus().ToControl();
			}
			System.IntPtr handle = WinSDK.SetFocus(SalWindow.GetSafeHandle(ctrl));
			return System.Windows.Forms.Control.FromHandle(handle);
		}
		private static void SetFocusAsync(System.Windows.Forms.Control target)
		{
			if (SalWindow.m_setFocusAsyncMessage == 0)
			{
				SalWindow.m_setFocusAsyncMessage = WinSDK.RegisterWindowMessage("PPJ.Runtime.Windows.SetFocusAsync");
			}
			WinSDK.ReleaseCapture();
			WinSDK.PostMessage(target.Handle, SalWindow.m_setFocusAsyncMessage, System.IntPtr.Zero, System.IntPtr.Zero);
		}
		public static bool SetDataLength(System.Windows.Forms.Control ctrl, int maxLength)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return false;
			}
			if (maxLength == -1)
			{
				maxLength = 0;
			}
			salEditControl.MaxLength = maxLength;
			return true;
		}
		public static bool IsEmpty(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (!SalWindow.IsEditControl(ctrl))
			{
				return false;
			}
			
			return ctrl.Text.Length == 0;
		}
		public static bool IsValidDateTime(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (!SalWindow.IsEditControl(ctrl))
			{
				return false;
			}
			SalString salString = SalWindow.GetTextWithMask(ctrl);
			return salString.IsValidDateTime(SalWindow.GetFormat(ctrl), SalWindow.GetCultureInfo(ctrl));
		}
		public static bool IsValidDecimal(System.Windows.Forms.Control ctrl, int precision, int scale)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (!SalWindow.IsEditControl(ctrl))
			{
				return false;
			}
			SalString salString = SalWindow.GetTextWithMask(ctrl);
			return salString.IsValidDecimal(precision, scale, SalWindow.GetFormat(ctrl), SalWindow.GetCultureInfo(ctrl));
		}
		public static bool IsValidInteger(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (!SalWindow.IsEditControl(ctrl))
			{
				return false;
			}
			SalString salString = SalWindow.GetTextWithMask(ctrl);
			return salString.IsValidInteger(SalWindow.GetFormat(ctrl));
		}
		public static bool IsValidNumber(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (!SalWindow.IsEditControl(ctrl))
			{
				return false;
			}
			SalString salString = SalWindow.GetTextWithoutMask(ctrl);
			return salString.IsValidNumber(SalWindow.GetFormat(ctrl), SalWindow.GetCultureInfo(ctrl));
		}
		public static string GetFormattedText(System.Windows.Forms.Control ctrl, bool format)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (!SalWindow.IsEditControl(ctrl))
			{
				return null;
			}
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return ctrl.Text;
			}
			object value = salEditControl.Value;
			if (value == null)
			{
				return string.Empty;
			}
			if (format)
			{
				switch (salEditControl.GetDataType())
				{
				case 2:
					return ((SalDateTime)value).ToString(salEditControl.Format);
				case 3:
					return ((SalNumber)value).ToString(salEditControl.Format);
				case 5:
					return SalWindow.GetTextWithMask(ctrl);
				}
			}
			return value.ToString();
		}
		internal static bool GetFormattedText(System.Windows.Forms.Control ctrl, ref SalString sText, bool format)
		{
			string formattedText = SalWindow.GetFormattedText(ctrl, format);
			if (formattedText == null)
			{
				return false;
			}
			sText = formattedText;
			return true;
		}
		public static string GetInputMask(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return null;
			}
			return salEditControl.EditMask;
		}
		internal static bool GetInputMask(System.Windows.Forms.Control ctrl, ref SalString sMask)
		{
			string inputMask = SalWindow.GetInputMask(ctrl);
			if (inputMask == string.Empty)
			{
				return false;
			}
			sMask = inputMask;
			return true;
		}
		public static string GetFormat(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return null;
			}
			return salEditControl.Format;
		}
		internal static bool GetFormat(System.Windows.Forms.Control ctrl, ref SalString sPicture)
		{
			string format = SalWindow.GetFormat(ctrl);
			if (format == null)
			{
				return false;
			}
			sPicture = format;
			return true;
		}
		private static string ConvertSalFormatToString(int format, int dataType)
		{
			switch (format)
			{
			case 1:
				if (dataType != 3)
				{
					return null;
				}
				return "C";
			case 2:
				if (dataType != 2)
				{
					return null;
				}
				return "d";
			case 3:
				if (dataType != 2)
				{
					return null;
				}
				return "G";
			case 4:
				if (dataType != 3)
				{
					return null;
				}
				return "N";
			case 6:
				if (dataType != 3)
				{
					return null;
				}
				return "P";
			case 7:
				if (dataType != 2)
				{
					return null;
				}
				return "T";
			}
			return null;
		}
		private static int ConvertStringToSalFormat(string format, int dataType)
		{
			switch (format)
			{
			case "d":
				if (dataType != 2)
				{
					return 0;
				}
				return 2;
			case "t":
				if (dataType != 2)
				{
					return 0;
				}
				return 7;
			case "g":
				if (dataType != 2)
				{
					return 0;
				}
				return 3;
			case "T":
				if (dataType != 2)
				{
					return 0;
				}
				return 7;
			case "G":
				if (dataType != 2)
				{
					return 0;
				}
				return 3;
			case "N":
				if (dataType != 3)
				{
					return 0;
				}
				return 4;
			case "C":
				if (dataType != 3)
				{
					return 0;
				}
				return 1;
			case "P":
				if (dataType != 3)
				{
					return 0;
				}
				return 6;
			}
			return 0;
		}
		public static int GetFormatCode(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl != null)
			{
				int num = SalWindow.ConvertStringToSalFormat(salEditControl.Format, salEditControl.GetDataType());
				if (num > 0)
				{
					return num;
				}
			}
			char c = '\0';
			System.Windows.Forms.CharacterCasing characterCasing = System.Windows.Forms.CharacterCasing.Normal;
			if (ctrl is System.Windows.Forms.TextBox)
			{
				c = ((System.Windows.Forms.TextBox)ctrl).PasswordChar;
				characterCasing = ((System.Windows.Forms.TextBox)ctrl).CharacterCasing;
			}
			
			switch (characterCasing)
			{
			case System.Windows.Forms.CharacterCasing.Upper:
				return 9;
			case System.Windows.Forms.CharacterCasing.Lower:
				return 8;
			default:
				if (c != '\0')
				{
					return 5;
				}
				if (salEditControl != null && salEditControl.Format != "")
				{
					return -1;
				}
				return 0;
			}
		}
		public static bool SetFormatCode(System.Windows.Forms.Control ctrl, int format)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl != null)
			{
				string text = SalWindow.ConvertSalFormatToString(format, salEditControl.GetDataType());
				if (text != null)
				{
					salEditControl.Format = text;
					return true;
				}
			}
			char passwordChar = '\0';
			System.Windows.Forms.CharacterCasing characterCasing = System.Windows.Forms.CharacterCasing.Normal;
			switch (format)
			{
			case -1:
				return true;
			case 0:
				if (salEditControl != null)
				{
					salEditControl.Format = "";
				}
				break;
			default:
				switch (format)
				{
				case 5:
					passwordChar = '*';
					goto IL_83;
				case 8:
					characterCasing = System.Windows.Forms.CharacterCasing.Lower;
					goto IL_83;
				case 9:
					characterCasing = System.Windows.Forms.CharacterCasing.Upper;
					goto IL_83;
				}
				return false;
			}
			IL_83:
			if (ctrl is System.Windows.Forms.TextBox)
			{
				((System.Windows.Forms.TextBox)ctrl).PasswordChar = passwordChar;
				((System.Windows.Forms.TextBox)ctrl).CharacterCasing = characterCasing;
				return true;
			}
			
			return false;
		}
		public static bool IsValid(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			return salEditControl != null && salEditControl.ValidateDataType();
		}
		public static bool IsValidEditMask(string mask)
		{
			if (string.IsNullOrEmpty(mask))
			{
				return false;
			}
			int num = mask.IndexOf('*');
			if (num > -1 && num != mask.Length - 1)
			{
				return false;
			}
			if (mask.LastIndexOf('*') != num)
			{
				return false;
			}
			bool result = false;
			for (int i = 0; i < mask.Length; i++)
			{
				if (IsMaskChar(mask[i]))
				{
					result = true;
					break;
				}
			}
			return result;
		}
        internal static bool IsMaskChar(char c)
        {
            if (c <= 'A')
            {
                if (c <= '*')
                {
                    if (c != '!' && c != '*')
                    {
                        return false;
                    }
                }
                else
                {
                    if (c != '9' && c != 'A')
                    {
                        return false;
                    }
                }
            }
            else
            {
                if (c <= 'X')
                {
                    if (c != 'N' && c != 'X')
                    {
                        return false;
                    }
                }
                else
                {
                    if (c != 'a' && c != 'n')
                    {
                        return false;
                    }
                }
            }
            return true;
        }
		public static bool SetInputMask(System.Windows.Forms.Control ctrl, string mask)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return false;
			}
			salEditControl.EditMask = mask;
			return true;
		}
		public static bool IsValidFormat(string format, int code)
		{
			bool result;
			try
			{
				switch (code)
				{
				case 1:
				{
					SalString salString = System.DateTime.Now.ToString(format);
					result = !salString.ToDate(format).IsNull;
					break;
				}
				case 2:
				{
					SalString salString2 = 1000.1m.ToString(format);
					result = !salString2.ToNumber(format).IsNull;
					break;
				}
				default:
					result = false;
					break;
				}
			}
			catch
			{
				result = false;
			}
			return result;
		}
		public static bool SetFormat(System.Windows.Forms.Control ctrl, string format)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return false;
			}
			if (format != null && format.Length > 2 && format.IndexOf('\u000f') > -1)
			{
				System.Globalization.CultureInfo invariantCulture = System.Globalization.CultureInfo.InvariantCulture;
				System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
				string text = format;
				int i = 0;
				while (i < text.Length)
				{
					char c = text[i];
					switch (c)
					{
					case '\u0001':
						stringBuilder.Append(invariantCulture.NumberFormat.NumberGroupSeparator);
						break;
					case '\u0002':
						stringBuilder.Append(invariantCulture.NumberFormat.NumberDecimalSeparator);
						break;
					case '\u0003':
						stringBuilder.Append(invariantCulture.NumberFormat.CurrencySymbol);
						break;
					case '\u0004':
						goto IL_CD;
					case '\u0005':
						stringBuilder.Append('(');
						break;
					case '\u0006':
						stringBuilder.Append(')');
						break;
					default:
						goto IL_CD;
					}
					IL_DA:
					i++;
					continue;
					IL_CD:
					if (c >= ' ')
					{
						stringBuilder.Append(c);
						goto IL_DA;
					}
					goto IL_DA;
				}
				format = stringBuilder.ToString();
			}
			salEditControl.Format = format;
			return true;
		}
		public static bool SetFormattedText(System.Windows.Forms.Control ctrl, string text, bool applyFormat)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return false;
			}
			salEditControl.Value = text;
			return true;
		}
		public static SalString GetTextUnmasked(System.Windows.Forms.Control ctrl)
		{
			SalString @null = SalString.Null;
			SalWindow.GetTextUnmasked(ctrl, ref @null);
			return @null;
		}
		internal static SalBoolean GetTextUnmasked(System.Windows.Forms.Control ctrl, ref SalString sText)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null || string.IsNullOrEmpty(salEditControl.EditMask))
			{
				return SalBoolean.False;
			}
			string textWithoutMask = SalWindow.GetTextWithoutMask(ctrl);
			sText = textWithoutMask;
			return SalBoolean.True;
		}
		public static bool Validate(System.Windows.Forms.Control ctrl, bool showErrorMessage)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return false;
			}
			if (salEditControl.ValidateDataType())
			{
				salEditControl.ApplyFormat();
				return true;
			}
			if (showErrorMessage)
			{
				SalWindow.ShowInvalidDataMsgBox(salEditControl);
				return false;
			}
			return false;
		}
		public static int GetDataType(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalControl salControl = ctrl as ISalControl;
			if (salControl == null)
			{
				return 0;
			}
			return salControl.GetDataType();
		}
		public static int GetControlType(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			return SalWindow.GetControlTypeInternal(ctrl);
		}
		internal static int GetControlTypeInternal(System.Windows.Forms.Control ctrl)
		{
			if (ctrl == null)
			{
				return 0;
			}
			ISalWindow salWindow = ctrl as ISalWindow;
			if (salWindow != null)
			{
				return salWindow.GetWindowType();
			}
			if (ctrl is System.Windows.Forms.TextBoxBase)
			{
				if (!((System.Windows.Forms.TextBoxBase)ctrl).Multiline)
				{
					return 8;
				}
				return 16;
			}
			else
			{
				if (ctrl is System.Windows.Forms.ComboBox)
				{
					return 16384;
				}
				if (ctrl is System.Windows.Forms.ListBox)
				{
					return 8192;
				}
				if (ctrl is System.Windows.Forms.Label)
				{
					return 2048;
				}
				if (ctrl is System.Windows.Forms.CheckBox)
				{
					return 128;
				}
				if (ctrl is System.Windows.Forms.RadioButton)
				{
					return 64;
				}
				if (ctrl is System.Windows.Forms.PictureBox)
				{
					return 131072;
				}
				if (ctrl is System.Windows.Forms.Button)
				{
					return 32;
				}
				if (ctrl is System.Windows.Forms.GroupBox)
				{
					return 256;
				}
				if (ctrl is System.Windows.Forms.VScrollBar)
				{
					return 1024;
				}
				if (ctrl is System.Windows.Forms.HScrollBar)
				{
					return 512;
				}
				if (ctrl is System.Windows.Forms.UserControl)
				{
					return 67108864;
				}
				if (ctrl is System.Windows.Forms.AxHost)
				{
					return 134217728;
				}
				if (!(ctrl is System.Windows.Forms.Form))
				{
					return 0;
				}
				System.Windows.Forms.Form form = (System.Windows.Forms.Form)ctrl;
				if (form.IsMdiContainer)
				{
					return 1048576;
				}
				if (form.Modal)
				{
					return 4;
				}
				return 1;
			}
		}
		public static int GetDataLength(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl == null)
			{
				return 0;
			}
			int num = salEditControl.MaxLength;
			if (num == 0 || num == 32767)
			{
				num = -1;
			}
			return num;
		}
		public static bool IsModified(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			ISalControl salControl = ctrl as ISalControl;
			return salControl != null && salControl.Modified;
		}
		public static int GetProfile(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Globalization.CultureInfo cultureInfo = SalWindow.GetCultureInfo(ctrl);
			if (cultureInfo == null)
			{
				return 0;
			}
			if (!cultureInfo.IsReadOnly)
			{
				return -1;
			}
			if (cultureInfo.IsNeutralCulture || cultureInfo.LCID == System.Globalization.CultureInfo.InvariantCulture.LCID)
			{
				return cultureInfo.LCID;
			}
			System.Globalization.RegionInfo regionInfo = new System.Globalization.RegionInfo(cultureInfo.LCID);
			string name;
			switch (name = regionInfo.Name)
			{
			case "US":
				return 1;
			case "AU":
				return 61;
			case "BE":
				return 32;
			case "BR":
				return 55;
			case "DK":
				return 45;
			case "FI":
				return 358;
			case "FR":
				return 33;
			case "DE":
				return 49;
			case "IT":
				return 39;
			case "JP":
				return 81;
			case "NL":
				return 31;
			case "NO":
				return 47;
			case "ES":
				return 34;
			case "SE":
				return 46;
			case "CH":
				return 41;
			case "UK":
				return 44;
			}
			return cultureInfo.LCID;
		}
		public static bool SetProfile(System.Windows.Forms.Control ctrl, int profile)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl != null)
			{
				if (profile == -1)
				{
					salEditControl.CultureInfo = (System.Globalization.CultureInfo)System.Globalization.CultureInfo.CurrentCulture.Clone();
				}
				else
				{
					salEditControl.CultureInfo = SalWindow.TranslateProfile(profile);
				}
			}
			return true;
		}
		public static bool GetProfileParameter(System.Windows.Forms.Control ctrl, int paramCode, ref SalNumber paramValue)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Globalization.CultureInfo cultureInfo = SalWindow.GetCultureInfo(ctrl);
			if (cultureInfo == null)
			{
				cultureInfo = System.Globalization.CultureInfo.CurrentCulture;
			}
			int x;
			switch (paramCode)
			{
			case 1:
				x = cultureInfo.NumberFormat.CurrencyPositivePattern;
				goto IL_F8;
			case 2:
				break;
			case 3:
				x = cultureInfo.NumberFormat.NumberDecimalDigits;
				goto IL_F8;
			case 4:
				x = 0;
				goto IL_F8;
			case 5:
				x = (cultureInfo.DateTimeFormat.LongTimePattern.EndsWith("tt") ? 0 : 1);
				goto IL_F8;
			default:
				switch (paramCode)
				{
				case 13:
					x = 0;
					goto IL_F8;
				case 16:
					x = ((cultureInfo.DateTimeFormat.LongTimePattern.IndexOf("hh") > -1 || cultureInfo.DateTimeFormat.LongTimePattern.IndexOf("HH") > -1) ? 1 : 0);
					goto IL_F8;
				case 17:
					x = cultureInfo.NumberFormat.CurrencyDecimalDigits;
					goto IL_F8;
				case 18:
					x = cultureInfo.NumberFormat.CurrencyNegativePattern;
					goto IL_F8;
				}
				break;
			}
			return false;
			IL_F8:
			paramValue = x;
			return true;
		}
		public static bool GetProfileParameter(System.Windows.Forms.Control ctrl, int paramCode, ref SalString paramValue)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Globalization.CultureInfo cultureInfo = SalWindow.GetCultureInfo(ctrl);
			if (cultureInfo == null)
			{
				cultureInfo = System.Globalization.CultureInfo.CurrentCulture;
			}
			string x;
			switch (paramCode)
			{
			case 6:
				x = cultureInfo.DateTimeFormat.AMDesignator;
				goto IL_C4;
			case 7:
				x = cultureInfo.DateTimeFormat.PMDesignator;
				goto IL_C4;
			case 8:
				x = cultureInfo.NumberFormat.CurrencySymbol;
				goto IL_C4;
			case 10:
				x = cultureInfo.NumberFormat.NumberDecimalSeparator;
				goto IL_C4;
			case 11:
				x = cultureInfo.NumberFormat.NumberGroupSeparator;
				goto IL_C4;
			case 12:
				x = cultureInfo.DateTimeFormat.TimeSeparator;
				goto IL_C4;
			case 14:
				x = cultureInfo.DateTimeFormat.ShortDatePattern;
				goto IL_C4;
			case 15:
				x = cultureInfo.DateTimeFormat.LongDatePattern;
				goto IL_C4;
			}
			return false;
			IL_C4:
			paramValue = x;
			return true;
		}
		public static bool SetProfileParameter(System.Windows.Forms.Control ctrl, int paramCode, SalNumber paramValue)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Globalization.CultureInfo cultureInfo = SalWindow.GetCultureInfo(ctrl);
			if (cultureInfo == null || cultureInfo.IsReadOnly)
			{
				return false;
			}
			int num = paramValue;
			switch (paramCode)
			{
			case 1:
				cultureInfo.NumberFormat.CurrencyPositivePattern = num;
				return true;
			case 2:
				break;
			case 3:
				cultureInfo.NumberFormat.NumberDecimalDigits = num;
				return true;
			case 4:
				return true;
			case 5:
				switch (num)
				{
				case 0:
					if (!cultureInfo.DateTimeFormat.LongTimePattern.EndsWith("tt"))
					{
						System.Globalization.DateTimeFormatInfo expr_DD = cultureInfo.DateTimeFormat;
						expr_DD.LongTimePattern += " tt";
						cultureInfo.DateTimeFormat.LongTimePattern = cultureInfo.DateTimeFormat.LongTimePattern.Replace("hh", "h");
						cultureInfo.DateTimeFormat.LongTimePattern = cultureInfo.DateTimeFormat.LongTimePattern.Replace("HH", "H");
					}
					if (!cultureInfo.DateTimeFormat.ShortTimePattern.EndsWith("tt"))
					{
						System.Globalization.DateTimeFormatInfo expr_15C = cultureInfo.DateTimeFormat;
						expr_15C.ShortTimePattern += " tt";
						cultureInfo.DateTimeFormat.ShortTimePattern = cultureInfo.DateTimeFormat.ShortTimePattern.Replace("hh", "h");
						cultureInfo.DateTimeFormat.ShortTimePattern = cultureInfo.DateTimeFormat.ShortTimePattern.Replace("HH", "H");
						return true;
					}
					return true;
				case 1:
					if (cultureInfo.DateTimeFormat.LongTimePattern.EndsWith("tt"))
					{
						cultureInfo.DateTimeFormat.LongTimePattern = cultureInfo.DateTimeFormat.LongTimePattern.Replace("tt", "");
						cultureInfo.DateTimeFormat.LongTimePattern = cultureInfo.DateTimeFormat.LongTimePattern.Replace("h", "hh");
						cultureInfo.DateTimeFormat.LongTimePattern = cultureInfo.DateTimeFormat.LongTimePattern.Replace("H", "HH");
					}
					if (!cultureInfo.DateTimeFormat.ShortTimePattern.EndsWith("tt"))
					{
						cultureInfo.DateTimeFormat.ShortTimePattern = cultureInfo.DateTimeFormat.ShortTimePattern.Replace("tt", "");
						cultureInfo.DateTimeFormat.ShortTimePattern = cultureInfo.DateTimeFormat.ShortTimePattern.Replace("h", "hh");
						cultureInfo.DateTimeFormat.ShortTimePattern = cultureInfo.DateTimeFormat.ShortTimePattern.Replace("H", "HH");
						return true;
					}
					return true;
				default:
					return false;
				}
				break;
			default:
				switch (paramCode)
				{
				case 13:
				case 16:
					return true;
				case 17:
					cultureInfo.NumberFormat.CurrencyDecimalDigits = num;
					return true;
				case 18:
					cultureInfo.NumberFormat.CurrencyNegativePattern = num;
					return true;
				}
				break;
			}
			return false;
		}
		public static bool SetProfileParameter(System.Windows.Forms.Control ctrl, int paramCode, SalString paramValue)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Globalization.CultureInfo cultureInfo = SalWindow.GetCultureInfo(ctrl);
			if (cultureInfo == null || cultureInfo.IsReadOnly)
			{
				return false;
			}
			string text = paramValue;
			switch (paramCode)
			{
			case 6:
				cultureInfo.DateTimeFormat.AMDesignator = text;
				return true;
			case 7:
				cultureInfo.DateTimeFormat.PMDesignator = text;
				return true;
			case 8:
				cultureInfo.NumberFormat.CurrencySymbol = text;
				return true;
			case 10:
				cultureInfo.NumberFormat.NumberDecimalSeparator = text;
				return true;
			case 11:
				cultureInfo.NumberFormat.NumberGroupSeparator = text;
				return true;
			case 12:
				cultureInfo.DateTimeFormat.TimeSeparator = text;
				return true;
			case 14:
				cultureInfo.DateTimeFormat.ShortDatePattern = text;
				return true;
			case 15:
				cultureInfo.DateTimeFormat.LongDatePattern = text;
				return true;
			}
			return false;
		}
		public static bool CopyProfile(System.Windows.Forms.Control ctrl, int profile)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			ISalEditControl salEditControl = ctrl as ISalEditControl;
			if (salEditControl != null)
			{
				if (salEditControl.CultureInfo == null || salEditControl.CultureInfo.IsReadOnly)
				{
					return false;
				}
				System.Globalization.CultureInfo cultureInfo = SalWindow.TranslateProfile(profile);
				salEditControl.CultureInfo.NumberFormat = cultureInfo.NumberFormat;
				salEditControl.CultureInfo.DateTimeFormat = cultureInfo.DateTimeFormat;
			}
			return true;
		}
		public static System.Globalization.CultureInfo TranslateProfile(int profile)
		{
			string name;
			if (profile <= 55)
			{
				switch (profile)
				{
				case 0:
					return System.Globalization.CultureInfo.CurrentCulture;
				case 1:
					name = "en-US";
					goto IL_121;
				default:
					switch (profile)
					{
					case 31:
						name = "nl-NL";
						goto IL_121;
					case 32:
						name = "nl-BE";
						goto IL_121;
					case 33:
						name = "fr-FR";
						goto IL_121;
					case 34:
						name = "es-ES";
						goto IL_121;
					case 35:
					case 36:
					case 37:
					case 38:
					case 40:
					case 42:
					case 43:
					case 48:
						break;
					case 39:
						name = "it-IT";
						goto IL_121;
					case 41:
						name = "it-CH";
						goto IL_121;
					case 44:
						name = "en-GB";
						goto IL_121;
					case 45:
						name = "da-DK";
						goto IL_121;
					case 46:
						name = "sv-SE";
						goto IL_121;
					case 47:
						name = "nb-NO";
						goto IL_121;
					case 49:
						name = "de-DE";
						goto IL_121;
					default:
						if (profile == 55)
						{
							name = "pt-BR";
							goto IL_121;
						}
						break;
					}
					break;
				}
			}
			else
			{
				if (profile == 61)
				{
					name = "en-AU";
					goto IL_121;
				}
				if (profile == 81)
				{
					name = "ja-JP";
					goto IL_121;
				}
				if (profile == 358)
				{
					name = "fi-FI";
					goto IL_121;
				}
			}
			return System.Globalization.CultureInfo.GetCultureInfo(profile);
			IL_121:
			return System.Globalization.CultureInfo.GetCultureInfo(name);
		}
		public static bool GetFont(System.Windows.Forms.Control ctrl, ref SalString sName, ref SalNumber nSize, ref SalNumber nEnhancement)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			string x = "";
			float num = 0f;
			int x2 = 0;
			if (!SalWindow.GetFont(ctrl.Font, ref x, ref num, ref x2))
			{
				return false;
			}
			sName = x;
			nSize = num;
			nEnhancement = x2;
			return true;
		}
		public static bool GetFont(Font font, ref string name, ref float size, ref int enhancement)
		{
			if (font == null)
			{
				return false;
			}
			name = font.Name;
			size = font.SizeInPoints;
			enhancement = ((font.Bold ? 8 : 0) | (font.Italic ? 2 : 0) | (font.Strikeout ? 16 : 0) | (font.Underline ? 4 : 0));
			return true;
		}
		public static string[] GetFontNames()
		{
			InstalledFontCollection installedFontCollection = new InstalledFontCollection();
			string[] array = new string[installedFontCollection.Families.Length];
			for (int i = 0; i < installedFontCollection.Families.Length; i++)
			{
				array[i] = installedFontCollection.Families[i].Name;
			}
			return array;
		}
		public static bool SetFont(System.Windows.Forms.Control ctrl, string name, int size, int enhancement)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			if (ctrl == null)
			{
				return false;
			}
			Font font = SalWindow.CreateFont(name, size, enhancement);
			if (font == null)
			{
				return false;
			}
			ctrl.Font = font;
			return true;
		}
		public static Font CreateFont(string name, int size, int enhancement)
		{
			if (name == null || name.Length == 0)
			{
				return null;
			}
			FontStyle style = (((enhancement & 8) == 8) ? FontStyle.Bold : FontStyle.Regular) | (((enhancement & 2) == 2) ? FontStyle.Italic : FontStyle.Regular) | (((enhancement & 4) == 4) ? FontStyle.Underline : FontStyle.Regular) | (((enhancement & 16) == 16) ? FontStyle.Strikeout : FontStyle.Regular);
			size = ((size <= 0) ? 8 : size);
			return new Font(name, (float)size, style, GraphicsUnit.Point);
		}
		public static bool MDIArrangeIcons(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form == null || !form.IsMdiContainer)
			{
				return false;
			}
			if (!form.IsMdiContainer)
			{
				return false;
			}
			form.LayoutMdi(System.Windows.Forms.MdiLayout.ArrangeIcons);
			return true;
		}
		public static bool MDICascade(System.Windows.Forms.Control ctrl)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form == null || !form.IsMdiContainer)
			{
				return false;
			}
			if (!form.IsMdiContainer)
			{
				return false;
			}
			form.LayoutMdi(System.Windows.Forms.MdiLayout.Cascade);
			return true;
		}
		public static bool MDITile(System.Windows.Forms.Control ctrl, bool vertical)
		{
			ctrl = SalWindow.TranslateControl(ctrl);
			System.Windows.Forms.Form form = ctrl as System.Windows.Forms.Form;
			if (form == null || !form.IsMdiContainer)
			{
				return false;
			}
			if (vertical)
			{
				form.LayoutMdi(System.Windows.Forms.MdiLayout.TileVertical);
			}
			else
			{
				form.LayoutMdi(System.Windows.Forms.MdiLayout.TileHorizontal);
			}
			return true;
		}
		public static int GetScrollBarPosition(System.Windows.Forms.Control ctrl)
		{
			System.Windows.Forms.ScrollBar scrollBar = SalWindow.TranslateControl(ctrl) as System.Windows.Forms.ScrollBar;
			if (scrollBar == null)
			{
				return 0;
			}
			return scrollBar.Value;
		}
		internal static bool GetScrollBarPosition(System.Windows.Forms.Control ctrl, ref SalNumber nPos)
		{
			if (ctrl == null)
			{
				return false;
			}
			System.Windows.Forms.ScrollBar scrollBar = SalWindow.TranslateControl(ctrl) as System.Windows.Forms.ScrollBar;
			if (scrollBar != null)
			{
				nPos = scrollBar.Value;
			}
			else
			{
				nPos = 0;
			}
			return true;
		}
		
		
		
		
		
		private void ProcessOnDragEnter(System.Windows.Forms.DragEventArgs e)
		{
			if (SalWindow.DesignMode)
			{
				return;
			}
			if (!e.Data.GetDataPresent(System.Windows.Forms.DataFormats.FileDrop))
			{
				SalWindow.m_dropDisabled = false;
				this.SendSamDragMessage(8239);
				e.Effect = (SalWindow.m_dropDisabled ? System.Windows.Forms.DragDropEffects.None : System.Windows.Forms.DragDropEffects.Move);
				return;
			}
			SalWindow.m_dropTarget = this.FindDropFilesTarget();
			if (SalWindow.m_dropTarget == null)
			{
				e.Effect = System.Windows.Forms.DragDropEffects.None;
				return;
			}
			e.Effect = System.Windows.Forms.DragDropEffects.Copy;
			SalWindow.m_dropFilesData = e.Data.GetData(System.Windows.Forms.DataFormats.FileDrop);
		}
		
		private void ProcessOnDragLeave(System.EventArgs e)
		{
			if (SalWindow.DesignMode)
			{
				return;
			}
			if (SalWindow.m_dropFilesData != null)
			{
				SalWindow.m_dropTarget = null;
				SalWindow.m_dropFilesData = null;
				return;
			}
			this.SendSamDragMessage(8241);
		}
		
		private void ProcessOnDragOver(System.Windows.Forms.DragEventArgs e)
		{
			if (SalWindow.DesignMode)
			{
				return;
			}
			if (SalWindow.m_dropFilesData != null)
			{
				e.Effect = this.GetDragDropEffect(e);
				return;
			}
			this.SendSamDragMessage(8240);
			e.Effect = (SalWindow.m_dropDisabled ? System.Windows.Forms.DragDropEffects.None : this.GetDragDropEffect(e));
		}
		private System.Windows.Forms.DragDropEffects GetDragDropEffect(System.Windows.Forms.DragEventArgs e)
		{
			if ((e.AllowedEffect & System.Windows.Forms.DragDropEffects.Move) == System.Windows.Forms.DragDropEffects.Move)
			{
				return System.Windows.Forms.DragDropEffects.Move;
			}
			if ((e.AllowedEffect & System.Windows.Forms.DragDropEffects.Copy) == System.Windows.Forms.DragDropEffects.Copy)
			{
				return System.Windows.Forms.DragDropEffects.Copy;
			}
			if ((e.AllowedEffect & System.Windows.Forms.DragDropEffects.Link) == System.Windows.Forms.DragDropEffects.Link)
			{
				return System.Windows.Forms.DragDropEffects.Link;
			}
			if ((e.AllowedEffect & System.Windows.Forms.DragDropEffects.Scroll) == System.Windows.Forms.DragDropEffects.Scroll)
			{
				return System.Windows.Forms.DragDropEffects.Scroll;
			}
			return System.Windows.Forms.DragDropEffects.All;
		}
		
		
		
		private void ProcessOnGiveFeedback(System.Windows.Forms.GiveFeedbackEventArgs e)
		{
			if (SalWindow.DesignMode)
			{
				return;
			}
			if (SalWindow.m_dropTarget != null)
			{
				SalWindow salWindow = SalWindow.m_dropTarget;
				if (salWindow != null)
				{
					if (e.Effect != System.Windows.Forms.DragDropEffects.None && salWindow.DragDropCursor != null)
					{
						System.Windows.Forms.Cursor.Current = salWindow.DragDropCursor;
						e.UseDefaultCursors = false;
						return;
					}
					if (e.Effect == System.Windows.Forms.DragDropEffects.None && salWindow.DisableDropCursor != null)
					{
						System.Windows.Forms.Cursor.Current = salWindow.DisableDropCursor;
						e.UseDefaultCursors = false;
					}
				}
			}
		}
		private static void OnQueryContinueDrag(object sender, System.Windows.Forms.QueryContinueDragEventArgs e)
		{
			if (SalWindow.DesignMode)
			{
				return;
			}
			switch (e.Action)
			{
			case System.Windows.Forms.DragAction.Continue:
			case System.Windows.Forms.DragAction.Drop:
				break;
			default:
				if (SalWindow.m_dragSource == null || e.EscapePressed)
				{
					e.Action = System.Windows.Forms.DragAction.Cancel;
					return;
				}
				e.Action = System.Windows.Forms.DragAction.Continue;
				break;
			}
		}
		internal static bool AutoStartDragMode(System.Windows.Forms.Control ctrl, ref System.Windows.Forms.Message m)
		{
			bool flag = false;
			Point mousePositionFromLParam = SalWindow.GetMousePositionFromLParam(m.LParam);
			if (!SalWindow.AutoStartDragModeInternal(SalWindow.TranslateControl(ctrl), mousePositionFromLParam.X, mousePositionFromLParam.Y, out flag))
			{
				if (flag && WinSDK.IsWindow(m.HWnd))
				{
					WinSDK.PostMessage(m.HWnd, 514, m.WParam, m.LParam);
				}
				return false;
			}
			return true;
		}
		internal static bool AutoStartDragMode(System.Windows.Forms.Control ctrl, System.Windows.Forms.MouseEventArgs e)
		{
			if (e.Clicks != 1 || e.Button != System.Windows.Forms.MouseButtons.Left)
			{
				return false;
			}
			int x = e.X;
			int y = e.Y;
			bool flag = false;
			return SalWindow.AutoStartDragModeInternal(SalWindow.TranslateControl(ctrl), x, y, out flag);
		}
		private static bool AutoStartDragModeInternal(System.Windows.Forms.Control ctrl, int x, int y, out bool dragDetectCalled)
		{
			dragDetectCalled = false;
			WindowActionsEventArgs windowActionsEventArgs = SalWindow.FireWindowActions(ctrl, 8243, x, y);
			if (windowActionsEventArgs.Handled && windowActionsEventArgs.Return != 0)
			{
				dragDetectCalled = true;
				if (WinSDK.DragDetect(ctrl.Handle, System.Windows.Forms.Control.MousePosition))
				{
					System.Windows.Forms.DataObject dragDataObject = SalWindow.GetDragDataObject(ctrl, x, y);
					SalWindow salWindow = ctrl;
					return salWindow.DragDropStartInternal(new Point(x, y), dragDataObject);
				}
			}
			return false;
		}
		private static System.Windows.Forms.DataObject GetDragDataObject(System.Windows.Forms.Control ctrl, int x, int y)
		{
			System.Windows.Forms.DataObject dataObject = new System.Windows.Forms.DataObject("");
			if (ctrl is System.Windows.Forms.PictureBox)
			{
				System.Windows.Forms.PictureBox pictureBox = (System.Windows.Forms.PictureBox)ctrl;
				if (pictureBox.Image != null)
				{
					dataObject.SetImage(pictureBox.Image);
				}
			}
			else
			{
				if (ctrl is System.Windows.Forms.ListBox)
				{
					System.Windows.Forms.ListBox listBox = (System.Windows.Forms.ListBox)ctrl;
					int num = listBox.IndexFromPoint(x, y);
					if (num > -1)
					{
						listBox.SelectedIndex = num;
					}
					string text = listBox.Text;
					if (!string.IsNullOrEmpty(text))
					{
						dataObject.SetText(text);
					}
				}
				else
				{
					if (!string.IsNullOrEmpty(ctrl.Text))
					{
						dataObject.SetText(ctrl.Text);
					}
				}
			}
			return dataObject;
		}
		private void SendSamDragMessage(int msg)
		{
			SalWindow.m_dropTarget = SalWindow.TranslateControl((System.Windows.Forms.Control)this.m_salWnd);
			SalWindow.m_dropLocation = SalWindow.m_dropTarget.PointToClient(System.Windows.Forms.Control.MousePosition);
			int x = (SalWindow.m_dragSource != null) ? ((int)SalWindow.m_dragSource.Handle) : 0;
			int x2 = 0;
			SalWindow.FireWindowActions(SalWindow.m_dropTarget, msg, x, x2);
			if (SalWindow.m_dragSource != null)
			{
				x = (int)SalWindow.m_dropTarget.Handle;
				SalWindow.FireWindowActions(SalWindow.m_dragSource, 8245, x, msg);
			}
		}
		public bool DragDropStart()
		{
			Point pt = ((System.Windows.Forms.Control)this.m_salWnd).PointToClient(System.Windows.Forms.Control.MousePosition);
			return this.DragDropStart(pt, null);
		}
		public bool DragDropStart(Point pt, object data)
		{
			if (System.Windows.Forms.Control.MouseButtons == System.Windows.Forms.MouseButtons.None)
			{
				return false;
			}
			data = ((data == null) ? string.Empty : data);
			return this.DragDropStartInternal(pt, data);
		}
		private bool DragDropStartInternal(Point pt, object data)
		{
			SalWindow.m_dropDisabled = false;
			SalWindow.m_dragSource = (System.Windows.Forms.Control)this.m_salWnd;
			SalWindow.m_dragLocation = pt;
			SalWindow.m_dropTarget = null;
			SalWindow.m_dropLocation = Point.Empty;
			try
			{
				int x = SalWindow.m_dragLocation.X;
				int y = SalWindow.m_dragLocation.Y;
				this.FireWindowActions(8238, x, y);
				if (SalWindow.m_dragSource != null)
				{
					SalWindow.m_dragSource.DoDragDrop(data, System.Windows.Forms.DragDropEffects.All);
				}
			}
			finally
			{
				this.FireWindowActions(8244, 0, 0);
				SalWindow.m_dropDisabled = false;
				SalWindow.m_dragSource = null;
				SalWindow.m_dragLocation = Point.Empty;
				SalWindow.m_dropTarget = null;
				SalWindow.m_dropLocation = Point.Empty;
			}
			return true;
		}
		public bool DragDropStop()
		{
			if (SalWindow.m_dragSource == null)
			{
				return false;
			}
			SalWindow.m_dragSource = null;
			return true;
		}
		internal static bool IsLocationOverSelectedText(Point pt, System.IntPtr handle, int selStart, int selLength)
		{
			if (selLength > 0)
			{
				System.IntPtr value = WinSDK.SendMessage(handle, 215, System.IntPtr.Zero, (System.IntPtr)(pt.Y << 16 | (pt.X & 65535)));
				if (value != System.IntPtr.Zero)
				{
					int num = (int)(value.ToInt64() & 65535L);
					num -= selStart;
					if (num >= 0 && num <= selLength)
					{
						return true;
					}
				}
			}
			return false;
		}
		public static void FillGradient(Graphics g, Color start, Color end, Rectangle bounds, bool vertical)
		{
			if (bounds.Width > 0 && bounds.Height > 0)
			{
				using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(bounds, start, end, vertical ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal))
				{
					g.FillRectangle(linearGradientBrush, bounds);
				}
			}
		}
		public static void FillDoubleGradient(Graphics g, Color start, Color middle, Color end, Rectangle bounds, int firstGradientSize, int secondGradientSize, bool vertical)
		{
			if (vertical)
			{
				Rectangle rect = bounds;
				rect.Height = firstGradientSize;
				if (rect.Width > 0 && rect.Height > 0)
				{
					using (LinearGradientBrush linearGradientBrush = new LinearGradientBrush(rect, start, middle, LinearGradientMode.Vertical))
					{
						g.FillRectangle(linearGradientBrush, rect);
					}
				}
				Rectangle rect2 = bounds;
				rect2.Height = secondGradientSize;
				rect2.Y = bounds.Bottom - secondGradientSize;
				if (rect2.Width > 0 && rect2.Height > 0)
				{
					using (LinearGradientBrush linearGradientBrush2 = new LinearGradientBrush(rect2, middle, end, LinearGradientMode.Vertical))
					{
						g.FillRectangle(linearGradientBrush2, rect2);
					}
				}
				bounds.Y += firstGradientSize;
				bounds.Height = System.Math.Max(bounds.Height - firstGradientSize - secondGradientSize + 1, 1);
				if (bounds.Width <= 0 || bounds.Height <= 0)
				{
					return;
				}
				using (SolidBrush solidBrush = new SolidBrush(middle))
				{
					g.FillRectangle(solidBrush, bounds);
					return;
				}
			}
			Rectangle rect3 = bounds;
			rect3.Width = firstGradientSize;
			if (rect3.Width > 0 && rect3.Height > 0)
			{
				using (LinearGradientBrush linearGradientBrush3 = new LinearGradientBrush(rect3, start, middle, LinearGradientMode.Horizontal))
				{
					g.FillRectangle(linearGradientBrush3, rect3);
				}
			}
			Rectangle rect4 = bounds;
			rect4.X = bounds.Right - secondGradientSize;
			rect4.Width = secondGradientSize;
			if (rect4.Width > 0 && rect4.Height > 0)
			{
				using (LinearGradientBrush linearGradientBrush4 = new LinearGradientBrush(rect4, middle, end, LinearGradientMode.Horizontal))
				{
					g.FillRectangle(linearGradientBrush4, rect4);
				}
			}
			bounds.X += firstGradientSize;
			bounds.Width = System.Math.Max(bounds.Width - firstGradientSize - secondGradientSize + 1, 1);
			if (bounds.Width > 0 && bounds.Height > 0)
			{
				using (SolidBrush solidBrush2 = new SolidBrush(middle))
				{
					g.FillRectangle(solidBrush2, bounds);
				}
			}
		}
		public static void EnablePostMessageQueueing()
		{
			if (!SalWindow.enablePostMessageQueueing)
			{
				SalWindow.enablePostMessageQueueing = true;
				SalWindow.postMessageQueue = new Queue<SalWindow.PostMessageQueueItem>();
				System.Windows.Forms.Application.Idle += new System.EventHandler(SalWindow.Application_Idle);
			}
		}
		[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
		public static void ForceNativePostMessageHandling()
		{
			SalWindow.forceNativePostMessageHandling = true;
		}
		private static void Application_Idle(object sender, System.EventArgs e)
		{
			if (SalWindow.enablePostMessageQueueing && !SalWindow.idlePostMessageDequeueingDisabled)
			{
				SalWindow.DequeueAllPostedMsgs(0);
			}
		}
		private static void DequeueAllPostedMsgs(int depth)
		{
			if (depth > 100)
			{
				throw new System.InvalidOperationException("Recursion level in post message dequeueing exceeding maximum at " + depth.ToString());
			}
			SalWindow.PostMessageQueueItem[] array = SalWindow.postMessageQueue.ToArray();
			SalWindow.postMessageQueue.Clear();
			for (int i = 0; i < array.Length; i++)
			{
				SalWindow.PostMessageQueueItem postMessageQueueItem = array[i];
				SalWindow.SendMessage(postMessageQueueItem.ctrl, postMessageQueueItem.msg, postMessageQueueItem.wParam, postMessageQueueItem.lParam);
			}
			if (SalWindow.postMessageQueue.Count > 0)
			{
				SalWindow.DequeueAllPostedMsgs(depth + 1);
			}
		}
		internal static string DateTimeFormatCustomize(string format)
		{
			if (format == null || (!(format == "T") && !(format == "G")))
			{
				return format;
			}
			string text = System.Globalization.DateTimeFormatInfo.CurrentInfo.LongTimePattern;
			if (text.ToUpper().Contains("H") && text.Contains("mm") && text.Contains("ss"))
			{
				return format;
			}
			if (text.ToUpper().Contains("H") && text.Contains("mm") && !text.Contains("ss"))
			{
				text = text + System.Globalization.DateTimeFormatInfo.CurrentInfo.TimeSeparator + "ss";
				if (format == "T")
				{
					return text;
				}
				return System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern + " " + text;
			}
			else
			{
				string text2 = string.Format("HH{0}mm{0}ss", System.Globalization.DateTimeFormatInfo.CurrentInfo.TimeSeparator);
				if (format == "T")
				{
					return text2;
				}
				return System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern + " " + text2;
			}
		}
		private void TraceWindowActions(WindowActionsEventArgs args)
		{
			if (Sys.TraceWindows.TraceVerbose && !SalWindow.IsSalMessage(args.ActionType))
			{
				System.Windows.Forms.Control control = args.hWnd.Control;
				if (control != null)
				{
					Sys.TraceVerbose(Sys.TraceWindows, "Process: Message: Window={0}, Message={1}, Name={2}, wParam={3}, lParam={4}, return={5}, handled={6}", new object[]
					{
						control.Name,
						args.ActionType,
						SalWindow.GetMessageName(args.ActionType),
						args.WParam,
						args.LParam,
						args.Return,
						args.Handled ? "yes" : "no"
					});
				}
			}
			if (Sys.TraceWindows.TraceInfo && SalWindow.IsSalMessage(args.ActionType))
			{
				System.Windows.Forms.Control control2 = args.hWnd.Control;
				if (control2 != null)
				{
					Sys.TraceInfo(Sys.TraceWindows, "Process: Message: Window={0}, Message={1}, Name={2}, wParam={3}, lParam={4}, return={5}, handled={6}", new object[]
					{
						control2.Name,
						args.ActionType,
						SalWindow.GetSalMessageName(args.ActionType),
						args.WParam,
						args.LParam,
						args.Return,
						args.Handled ? "yes" : "no"
					});
				}
			}
		}
	}
}
